Skip to content

Commit bab7cd4

Browse files
committed
Update tables
1 parent e55cb79 commit bab7cd4

5 files changed

+55
-55
lines changed

src/main/java/db/migration/V1639097360419__CreateTableUser.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ public void migrate(Context context) throws Exception {
1414
create.transaction(configuration -> {
1515
using(configuration)
1616
.createTableIfNotExists("user")
17-
.column("id", BIGINT.identity(true))
18-
.column("name", VARCHAR(100).nullable(false))
19-
.column("email", VARCHAR(100).nullable(true))
20-
.column("deleted_email", VARCHAR(100).nullable(true))
21-
.column("password", VARCHAR(100).nullable(false))
22-
.column("active", BOOLEAN.defaultValue(true))
23-
.column("created_at", TIMESTAMP.defaultValue(currentTimestamp()))
24-
.column("updated_at", TIMESTAMP.nullable(true))
25-
.column("deleted_at", TIMESTAMP.nullable(true))
26-
.column("created_by", BIGINT.nullable(true))
27-
.column("updated_by", BIGINT.nullable(true))
28-
.column("deleted_by", BIGINT.nullable(true))
17+
.column("id", BIGINT.identity(true))
18+
.column("name", VARCHAR(100).nullable(false))
19+
.column("email", VARCHAR(100).nullable(true))
20+
.column("deleted_email", VARCHAR(100).nullable(true))
21+
.column("password", VARCHAR(100).nullable(false))
22+
.column("active", BOOLEAN.defaultValue(true))
23+
.column("created_at", TIMESTAMP.defaultValue(currentTimestamp()))
24+
.column("updated_at", TIMESTAMP.nullable(true))
25+
.column("deleted_at", TIMESTAMP.nullable(true))
26+
.column("created_by", BIGINT.nullable(true))
27+
.column("updated_by", BIGINT.nullable(true))
28+
.column("deleted_by", BIGINT.nullable(true))
2929
.constraints(
30-
primaryKey("id"),
31-
unique("email"),
32-
foreignKey("created_by").references("user", "id"),
33-
foreignKey("updated_by").references("user", "id"),
34-
foreignKey("deleted_by").references("user", "id"))
30+
constraint("user_pk").primaryKey("id"),
31+
constraint("user_unique_email").unique("email"),
32+
constraint("user_created_by_fk").foreignKey("created_by").references("user", "id"),
33+
constraint("user_updated_by_fk").foreignKey("updated_by").references("user", "id"),
34+
constraint("user_deleted_by_fk").foreignKey("deleted_by").references("user", "id"))
3535
.execute();
3636
});
3737
}

src/main/java/db/migration/V1639097454131__CreateTableRole.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ public void migrate(Context context) throws Exception {
1414
create.transaction(configuration -> {
1515
using(configuration)
1616
.createTableIfNotExists("role")
17-
.column("id", BIGINT.identity(true))
18-
.column("name", VARCHAR(100).nullable(false))
19-
.column("deleted_name", VARCHAR(100).nullable(true))
20-
.column("initials", VARCHAR(100).nullable(false))
21-
.column("deleted_initials", VARCHAR(100).nullable(true))
22-
.column("description", VARCHAR(100).nullable(true))
23-
.column("active", BOOLEAN.defaultValue(true))
24-
.column("created_at", TIMESTAMP.defaultValue(currentTimestamp()))
25-
.column("updated_at", TIMESTAMP.nullable(true))
26-
.column("deleted_at", TIMESTAMP.nullable(true))
27-
.column("created_by", BIGINT.nullable(true))
28-
.column("updated_by", BIGINT.nullable(true))
29-
.column("deleted_by", BIGINT.nullable(true))
17+
.column("id", BIGINT.identity(true))
18+
.column("name", VARCHAR(100).nullable(false))
19+
.column("deleted_name", VARCHAR(100).nullable(true))
20+
.column("initials", VARCHAR(100).nullable(false))
21+
.column("deleted_initials", VARCHAR(100).nullable(true))
22+
.column("description", VARCHAR(100).nullable(true))
23+
.column("active", BOOLEAN.defaultValue(true))
24+
.column("created_at", TIMESTAMP.defaultValue(currentTimestamp()))
25+
.column("updated_at", TIMESTAMP.nullable(true))
26+
.column("deleted_at", TIMESTAMP.nullable(true))
27+
.column("created_by", BIGINT.nullable(true))
28+
.column("updated_by", BIGINT.nullable(true))
29+
.column("deleted_by", BIGINT.nullable(true))
3030
.constraints(
31-
primaryKey("id"),
32-
unique("name"),
33-
unique("initials"),
34-
foreignKey("created_by").references("user", "id"),
35-
foreignKey("updated_by").references("user", "id"),
36-
foreignKey("deleted_by").references("user", "id"))
31+
constraint("role_pk").primaryKey("id"),
32+
constraint("role_unique_name").unique("name"),
33+
constraint("role_unique_initials").unique("initials"),
34+
constraint("role_created_by_fk").foreignKey("created_by").references("user", "id"),
35+
constraint("role_updated_by_fk").foreignKey("updated_by").references("user", "id"),
36+
constraint("role_deleted_by_fk").foreignKey("deleted_by").references("user", "id"))
3737
.execute();
3838
});
3939
}

src/main/java/db/migration/V1639097544500__CreateTableUserRoleManyToMany.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public void migrate(Context context) throws Exception {
1414
create.transaction(configuration -> {
1515
using(configuration)
1616
.createTableIfNotExists("user_role")
17-
.column("user_id", BIGINT.nullable(true))
18-
.column("role_id", BIGINT.nullable(true))
17+
.column("user_id", BIGINT.nullable(true))
18+
.column("role_id", BIGINT.nullable(true))
1919
.constraints(
20-
foreignKey("user_id").references("user", "id"),
21-
foreignKey("role_id").references("role", "id"))
20+
constraint("user_role_fk").foreignKey("user_id").references("user", "id"),
21+
constraint("role_user_fk").foreignKey("role_id").references("role", "id"))
2222
.execute();
2323
});
2424
}

src/main/java/db/migration/V1639097619108__CreateTableRefreshToken.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public void migrate(Context context) throws Exception {
1414
create.transaction(configuration -> {
1515
using(configuration)
1616
.createTableIfNotExists("refresh_token")
17-
.column("id", BIGINT.identity(true))
18-
.column("code", VARCHAR(40).nullable(false))
19-
.column("available", BOOLEAN.defaultValue(true))
20-
.column("expires_in", TIMESTAMP.nullable(false))
21-
.column("user_id", BIGINT.nullable(false))
17+
.column("id", BIGINT.identity(true))
18+
.column("code", VARCHAR(40).nullable(false))
19+
.column("available", BOOLEAN.defaultValue(true))
20+
.column("expires_in", TIMESTAMP.nullable(false))
21+
.column("user_id", BIGINT.nullable(false))
2222
.constraints(
23-
primaryKey("id"),
24-
unique("code"),
25-
foreignKey("user_id").references("user", "id"))
23+
constraint("refresh_token_pk").primaryKey("id"),
24+
constraint("refresh_token_unique_code").unique("code"),
25+
constraint("refresh_token_user_fk").foreignKey("user_id").references("user", "id"))
2626
.execute();
2727
});
2828
}

src/main/java/db/migration/V1639097688772__CreateTableRecovery.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public void migrate(Context context) throws Exception {
1414
create.transaction(configuration -> {
1515
using(configuration)
1616
.createTableIfNotExists("recovery")
17-
.column("id", BIGINT.identity(true))
18-
.column("code", VARCHAR(4).nullable(false))
19-
.column("expires_in", TIMESTAMP.nullable(false))
20-
.column("user_id", BIGINT.nullable(false))
17+
.column("id", BIGINT.identity(true))
18+
.column("code", VARCHAR(4).nullable(false))
19+
.column("expires_in", TIMESTAMP.nullable(false))
20+
.column("user_id", BIGINT.nullable(false))
2121
.constraints(
22-
primaryKey("id"),
23-
unique("code"),
24-
foreignKey("user_id").references("user", "id"))
22+
constraint("recovery_pk").primaryKey("id"),
23+
constraint("recovery_unique_code").unique("code"),
24+
constraint("recovery_user_fk").foreignKey("user_id").references("user", "id"))
2525
.execute();
2626
});
2727
}

0 commit comments

Comments
 (0)