Merge pull request #158 from usbharu/feature/db-migration

feat: DBのマイグレーションをFlywayで行うように
This commit is contained in:
usbharu 2023-11-19 13:56:44 +09:00 committed by GitHub
commit 2d7440bd10
12 changed files with 211 additions and 18 deletions

View File

@ -182,6 +182,7 @@ dependencies {
implementation("org.apache.tika:tika-core:2.9.1") implementation("org.apache.tika:tika-core:2.9.1")
implementation("net.coobird:thumbnailator:0.4.20") implementation("net.coobird:thumbnailator:0.4.20")
implementation("org.bytedeco:javacv-platform:1.5.9") implementation("org.bytedeco:javacv-platform:1.5.9")
implementation("org.flywaydb:flyway-core")
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version") implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")

View File

@ -24,6 +24,6 @@ VALUES (9, 'test-user9', 'follower.example.com', 'Im test-user9.', 'THis account
insert into USERS_FOLLOWERS (USER_ID, FOLLOWER_ID) insert into USERS_FOLLOWERS (USER_ID, FOLLOWER_ID)
VALUES (8, 9); VALUES (8, 9);
insert into POSTS (ID, "userId", OVERVIEW, TEXT, "createdAt", VISIBILITY, URL, "repostId", "replyId", SENSITIVE, AP_ID) insert into POSTS (ID, USER_ID, OVERVIEW, TEXT, CREATED_AT, VISIBILITY, URL, REPLY_ID, REPOST_ID, SENSITIVE, AP_ID)
VALUES (1239, 8, null, 'test post', 12345680, 2, 'https://example.com/users/test-user8/posts/1239', null, null, false, VALUES (1239, 8, null, 'test post', 12345680, 2, 'https://example.com/users/test-user8/posts/1239', null, null, false,
'https://example.com/users/test-user8/posts/1239'); 'https://example.com/users/test-user8/posts/1239');

View File

@ -24,6 +24,7 @@ VALUES (5, 'test-user5', 'follower.example.com', 'Im test user5.', 'THis account
insert into USERS_FOLLOWERS (USER_ID, FOLLOWER_ID) insert into USERS_FOLLOWERS (USER_ID, FOLLOWER_ID)
VALUES (4, 5); VALUES (4, 5);
insert into POSTS (ID, "userId", OVERVIEW, TEXT, "createdAt", VISIBILITY, URL, "repostId", "replyId", SENSITIVE, AP_ID) insert into POSTS (ID, "USER_ID", OVERVIEW, TEXT, "CREATED_AT", VISIBILITY, URL, "REPOST_ID", "REPLY_ID", SENSITIVE,
AP_ID)
VALUES (1237, 4, null, 'test post', 12345680, 0, 'https://example.com/users/test-user4/posts/1237', null, null, false, VALUES (1237, 4, null, 'test post', 12345680, 0, 'https://example.com/users/test-user4/posts/1237', null, null, false,
'https://example.com/users/test-user4/posts/1237'); 'https://example.com/users/test-user4/posts/1237');

View File

@ -24,6 +24,7 @@ VALUES (7, 'test-user7', 'follower.example.com', 'Im test-user7.', 'THis account
insert into USERS_FOLLOWERS (USER_ID, FOLLOWER_ID) insert into USERS_FOLLOWERS (USER_ID, FOLLOWER_ID)
VALUES (6, 7); VALUES (6, 7);
insert into POSTS (ID, "userId", OVERVIEW, TEXT, "createdAt", VISIBILITY, URL, "repostId", "replyId", SENSITIVE, AP_ID) insert into POSTS (ID, "USER_ID", OVERVIEW, TEXT, "CREATED_AT", VISIBILITY, URL, "REPOST_ID", "REPLY_ID", SENSITIVE,
AP_ID)
VALUES (1238, 6, null, 'test post', 12345680, 1, 'https://example.com/users/test-user6/posts/1238', null, null, false, VALUES (1238, 6, null, 'test post', 12345680, 1, 'https://example.com/users/test-user6/posts/1238', null, null, false,
'https://example.com/users/test-user6/posts/1238'); 'https://example.com/users/test-user6/posts/1238');

View File

@ -9,7 +9,8 @@ VALUES (11, 'test-user11', 'example.com', 'Im test-user11.', 'THis account is te
'https://example.com/users/test-user11#pubkey', 'https://example.com/users/test-user11/following', 'https://example.com/users/test-user11#pubkey', 'https://example.com/users/test-user11/following',
'https://example.com/users/test-user11/followers', null); 'https://example.com/users/test-user11/followers', null);
insert into POSTS (ID, "userId", OVERVIEW, TEXT, "createdAt", VISIBILITY, URL, "repostId", "replyId", SENSITIVE, AP_ID) insert into POSTS (ID, "USER_ID", OVERVIEW, TEXT, "CREATED_AT", VISIBILITY, URL, "REPOST_ID", "REPLY_ID", SENSITIVE,
AP_ID)
VALUES (1242, 11, null, 'test post', 12345680, 0, 'https://example.com/users/test-user11/posts/1242', null, null, false, VALUES (1242, 11, null, 'test post', 12345680, 0, 'https://example.com/users/test-user11/posts/1242', null, null, false,
'https://example.com/users/test-user11/posts/1242'); 'https://example.com/users/test-user11/posts/1242');
@ -17,6 +18,6 @@ insert into MEDIA (ID, NAME, URL, REMOTE_URL, THUMBNAIL_URL, TYPE, BLURHASH, MIM
VALUES (1, 'test-media', 'https://example.com/media/test-media.png', null, null, 0, null, 'image/png', null), VALUES (1, 'test-media', 'https://example.com/media/test-media.png', null, null, 0, null, 'image/png', null),
(2, 'test-media2', 'https://example.com/media/test-media2.png', null, null, 0, null, 'image/png', null); (2, 'test-media2', 'https://example.com/media/test-media2.png', null, null, 0, null, 'image/png', null);
insert into POSTSMEDIA(POST_ID, MEDIA_ID) insert into POSTS_MEDIA(POST_ID, MEDIA_ID)
VALUES (1242, 1), VALUES (1242, 1),
(1242, 2); (1242, 2);

View File

@ -9,7 +9,8 @@ VALUES (10, 'test-user10', 'example.com', 'Im test-user10.', 'THis account is te
'https://example.com/users/test-user10#pubkey', 'https://example.com/users/test-user10/following', 'https://example.com/users/test-user10#pubkey', 'https://example.com/users/test-user10/following',
'https://example.com/users/test-user10/followers', null); 'https://example.com/users/test-user10/followers', null);
insert into POSTS (ID, "userId", OVERVIEW, TEXT, "createdAt", VISIBILITY, URL, "repostId", "replyId", SENSITIVE, AP_ID) insert into POSTS (ID, "USER_ID", OVERVIEW, TEXT, "CREATED_AT", VISIBILITY, URL, "REPOST_ID", "REPLY_ID", SENSITIVE,
AP_ID)
VALUES (1240, 10, null, 'test post', 12345680, 0, 'https://example.com/users/test-user10/posts/1240', null, null, false, VALUES (1240, 10, null, 'test post', 12345680, 0, 'https://example.com/users/test-user10/posts/1240', null, null, false,
'https://example.com/users/test-user10/posts/1240'), 'https://example.com/users/test-user10/posts/1240'),
(1241, 10, null, 'test post', 12345680, 0, 'https://example.com/users/test-user10/posts/1241', null, 1240, false, (1241, 10, null, 'test post', 12345680, 0, 'https://example.com/users/test-user10/posts/1241', null, 1240, false,

View File

@ -9,6 +9,7 @@ VALUES (3, 'test-user3', 'example.com', 'Im test user3.', 'THis account is test
'https://example.com/users/test-user3#pubkey', 'https://example.com/users/test-user3/following', 'https://example.com/users/test-user3#pubkey', 'https://example.com/users/test-user3/following',
'https://example.com/users/test-user3/followers', null); 'https://example.com/users/test-user3/followers', null);
insert into POSTS (ID, "userId", OVERVIEW, TEXT, "createdAt", VISIBILITY, URL, "repostId", "replyId", SENSITIVE, AP_ID) insert into POSTS (ID, "USER_ID", OVERVIEW, TEXT, "CREATED_AT", VISIBILITY, URL, "REPOST_ID", "REPLY_ID", SENSITIVE,
AP_ID)
VALUES (1236, 3, null, 'test post', 12345680, 2, 'https://example.com/users/test-user3/posts/1236', null, null, false, VALUES (1236, 3, null, 'test post', 12345680, 2, 'https://example.com/users/test-user3/posts/1236', null, null, false,
'https://example.com/users/test-user3/posts/1236') 'https://example.com/users/test-user3/posts/1236')

View File

@ -8,6 +8,7 @@ VALUES (1, 'test-user', 'example.com', 'Im test user.', 'THis account is test us
'https://example.com/users/test-user#pubkey', 'https://example.com/users/test-user/following', 'https://example.com/users/test-user#pubkey', 'https://example.com/users/test-user/following',
'https://example.com/users/test-users/followers', null); 'https://example.com/users/test-users/followers', null);
insert into POSTS (ID, "userId", OVERVIEW, TEXT, "createdAt", VISIBILITY, URL, "repostId", "replyId", SENSITIVE, AP_ID) insert into POSTS (ID, "USER_ID", OVERVIEW, TEXT, "CREATED_AT", VISIBILITY, URL, "REPOST_ID", "REPLY_ID", SENSITIVE,
AP_ID)
VALUES (1234, 1, null, 'test post', 12345680, 0, 'https://example.com/users/test-user/posts/1234', null, null, false, VALUES (1234, 1, null, 'test post', 12345680, 0, 'https://example.com/users/test-user/posts/1234', null, null, false,
'https://example.com/users/test-user/posts/1234') 'https://example.com/users/test-user/posts/1234')

View File

@ -9,6 +9,7 @@ VALUES (2, 'test-user2', 'example.com', 'Im test user2.', 'THis account is test
'https://example.com/users/test-user2#pubkey', 'https://example.com/users/test-user2/following', 'https://example.com/users/test-user2#pubkey', 'https://example.com/users/test-user2/following',
'https://example.com/users/test-user2/followers', null); 'https://example.com/users/test-user2/followers', null);
insert into POSTS (ID, "userId", OVERVIEW, TEXT, "createdAt", VISIBILITY, URL, "repostId", "replyId", SENSITIVE, AP_ID) insert into POSTS (ID, "USER_ID", OVERVIEW, TEXT, "CREATED_AT", VISIBILITY, URL, "REPOST_ID", "REPLY_ID", SENSITIVE,
AP_ID)
VALUES (1235, 2, null, 'test post', 12345680, 1, 'https://example.com/users/test-user2/posts/1235', null, null, false, VALUES (1235, 2, null, 'test post', 12345680, 1, 'https://example.com/users/test-user2/posts/1235', null, null, false,
'https://example.com/users/test-user2/posts/1235') 'https://example.com/users/test-user2/posts/1235')

View File

@ -75,20 +75,20 @@ class PostRepositoryImpl(
object Posts : Table() { object Posts : Table() {
val id: Column<Long> = long("id") val id: Column<Long> = long("id")
val userId: Column<Long> = long("userId").references(Users.id) val userId: Column<Long> = long("user_id").references(Users.id)
val overview: Column<String?> = varchar("overview", 100).nullable() val overview: Column<String?> = varchar("overview", 100).nullable()
val text: Column<String> = varchar("text", 3000) val text: Column<String> = varchar("text", 3000)
val createdAt: Column<Long> = long("createdAt") val createdAt: Column<Long> = long("created_at")
val visibility: Column<Int> = integer("visibility").default(0) val visibility: Column<Int> = integer("visibility").default(0)
val url: Column<String> = varchar("url", 500) val url: Column<String> = varchar("url", 500)
val repostId: Column<Long?> = long("repostId").references(id).nullable() val repostId: Column<Long?> = long("repost_id").references(id).nullable()
val replyId: Column<Long?> = long("replyId").references(id).nullable() val replyId: Column<Long?> = long("reply_id").references(id).nullable()
val sensitive: Column<Boolean> = bool("sensitive").default(false) val sensitive: Column<Boolean> = bool("sensitive").default(false)
val apId: Column<String> = varchar("ap_id", 100).uniqueIndex() val apId: Column<String> = varchar("ap_id", 100).uniqueIndex()
override val primaryKey: PrimaryKey = PrimaryKey(id) override val primaryKey: PrimaryKey = PrimaryKey(id)
} }
object PostsMedia : Table() { object PostsMedia : Table("posts_media") {
val postId = long("post_id").references(Posts.id, ReferenceOption.CASCADE, ReferenceOption.CASCADE) val postId = long("post_id").references(Posts.id, ReferenceOption.CASCADE, ReferenceOption.CASCADE)
val mediaId = long("media_id").references(Media.id, ReferenceOption.CASCADE, ReferenceOption.CASCADE) val mediaId = long("media_id").references(Media.id, ReferenceOption.CASCADE, ReferenceOption.CASCADE)
override val primaryKey = PrimaryKey(postId, mediaId) override val primaryKey = PrimaryKey(postId, mediaId)

View File

@ -19,7 +19,7 @@ spring:
default-property-inclusion: always default-property-inclusion: always
datasource: datasource:
driver-class-name: org.h2.Driver driver-class-name: org.h2.Driver
url: "jdbc:h2:./test-dev3;MODE=POSTGRESQL;TRACE_LEVEL_FILE=4" url: "jdbc:h2:./test-dev4;MODE=POSTGRESQL;TRACE_LEVEL_FILE=4"
username: "" username: ""
password: "" password: ""
# data: # data:
@ -37,9 +37,6 @@ spring:
h2: h2:
console: console:
enabled: true enabled: true
exposed:
generate-ddl: true
excluded-packages: dev.usbharu.hideout.core.infrastructure.kjobexposed
server: server:
tomcat: tomcat:
basedir: tomcat basedir: tomcat

View File

@ -0,0 +1,188 @@
CREATE TABLE IF NOT EXISTS "INSTANCE"
(
ID BIGINT PRIMARY KEY,
"NAME" VARCHAR(1000) NOT NULL,
DESCRIPTION VARCHAR(5000) NOT NULL,
URL VARCHAR(255) NOT NULL,
ICON_URL VARCHAR(255) NOT NULL,
SHARED_INBOX VARCHAR(255) NULL,
SOFTWARE VARCHAR(255) NOT NULL,
VERSION VARCHAR(255) NOT NULL,
IS_BLOCKED BOOLEAN NOT NULL,
IS_MUTED BOOLEAN NOT NULL,
MODERATION_NOTE VARCHAR(10000) NOT NULL,
CREATED_AT TIMESTAMP NOT NULL
);
CREATE TABLE IF NOT EXISTS USERS
(
ID BIGINT PRIMARY KEY,
"NAME" VARCHAR(300) NOT NULL,
"DOMAIN" VARCHAR(1000) NOT NULL,
SCREEN_NAME VARCHAR(300) NOT NULL,
DESCRIPTION VARCHAR(10000) NOT NULL,
PASSWORD VARCHAR(255) NULL,
INBOX VARCHAR(1000) NOT NULL,
OUTBOX VARCHAR(1000) NOT NULL,
URL VARCHAR(1000) NOT NULL,
PUBLIC_KEY VARCHAR(10000) NOT NULL,
PRIVATE_KEY VARCHAR(10000) NULL,
CREATED_AT BIGINT NOT NULL,
KEY_ID VARCHAR(1000) NOT NULL,
"FOLLOWING" VARCHAR(1000) NULL,
FOLLOWERS VARCHAR(1000) NULL,
"INSTANCE" BIGINT NULL,
CONSTRAINT FK_USERS_INSTANCE__ID FOREIGN KEY ("INSTANCE") REFERENCES "INSTANCE" (ID) ON DELETE RESTRICT ON UPDATE RESTRICT
);
CREATE TABLE IF NOT EXISTS FOLLOW_REQUESTS
(
ID BIGSERIAL PRIMARY KEY,
USER_ID BIGINT NOT NULL,
FOLLOWER_ID BIGINT NOT NULL,
CONSTRAINT FK_FOLLOW_REQUESTS_USER_ID__ID FOREIGN KEY (USER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT FK_FOLLOW_REQUESTS_FOLLOWER_ID__ID FOREIGN KEY (FOLLOWER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT
);
CREATE TABLE IF NOT EXISTS MEDIA
(
ID BIGINT PRIMARY KEY,
"NAME" VARCHAR(255) NOT NULL,
URL VARCHAR(255) NOT NULL,
REMOTE_URL VARCHAR(255) NULL,
THUMBNAIL_URL VARCHAR(255) NULL,
"TYPE" INT NOT NULL,
BLURHASH VARCHAR(255) NULL,
MIME_TYPE VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(4000) NULL
);
CREATE TABLE IF NOT EXISTS META_INFO
(
ID BIGINT PRIMARY KEY,
VERSION VARCHAR(1000) NOT NULL,
KID VARCHAR(1000) NOT NULL,
JWT_PRIVATE_KEY VARCHAR(100000) NOT NULL,
JWT_PUBLIC_KEY VARCHAR(100000) NOT NULL
);
CREATE TABLE IF NOT EXISTS POSTS
(
ID BIGINT PRIMARY KEY,
USER_ID BIGINT NOT NULL,
OVERVIEW VARCHAR(100) NULL,
TEXT VARCHAR(3000) NOT NULL,
CREATED_AT BIGINT NOT NULL,
VISIBILITY INT DEFAULT 0 NOT NULL,
URL VARCHAR(500) NOT NULL,
REPOST_ID BIGINT NULL,
REPLY_ID BIGINT NULL,
"SENSITIVE" BOOLEAN DEFAULT FALSE NOT NULL,
AP_ID VARCHAR(100) NOT NULL
);
ALTER TABLE POSTS
ADD CONSTRAINT FK_POSTS_USERID__ID FOREIGN KEY (USER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE POSTS
ADD CONSTRAINT FK_POSTS_REPOSTID__ID FOREIGN KEY (REPOST_ID) REFERENCES POSTS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE POSTS
ADD CONSTRAINT FK_POSTS_REPLYID__ID FOREIGN KEY (REPLY_ID) REFERENCES POSTS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT;
CREATE TABLE IF NOT EXISTS POSTS_MEDIA
(
POST_ID BIGINT,
MEDIA_ID BIGINT,
CONSTRAINT pk_PostsMedia PRIMARY KEY (POST_ID, MEDIA_ID)
);
ALTER TABLE POSTS_MEDIA
ADD CONSTRAINT FK_POSTS_MEDIA_POST_ID__ID FOREIGN KEY (POST_ID) REFERENCES POSTS (ID) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE POSTS_MEDIA
ADD CONSTRAINT FK_POSTS_MEDIA_MEDIA_ID__ID FOREIGN KEY (MEDIA_ID) REFERENCES MEDIA (ID) ON DELETE CASCADE ON UPDATE CASCADE;
CREATE TABLE IF NOT EXISTS REACTIONS
(
ID BIGSERIAL PRIMARY KEY,
EMOJI_ID BIGINT NOT NULL,
POST_ID BIGINT NOT NULL,
USER_ID BIGINT NOT NULL
);
ALTER TABLE REACTIONS
ADD CONSTRAINT FK_REACTIONS_POST_ID__ID FOREIGN KEY (POST_ID) REFERENCES POSTS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE REACTIONS
ADD CONSTRAINT FK_REACTIONS_USER_ID__ID FOREIGN KEY (USER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT;
CREATE TABLE IF NOT EXISTS TIMELINES
(
ID BIGINT PRIMARY KEY,
USER_ID BIGINT NOT NULL,
TIMELINE_ID BIGINT NOT NULL,
POST_ID BIGINT NOT NULL,
POST_USER_ID BIGINT NOT NULL,
CREATED_AT BIGINT NOT NULL,
REPLY_ID BIGINT NULL,
REPOST_ID BIGINT NULL,
VISIBILITY INT NOT NULL,
"SENSITIVE" BOOLEAN NOT NULL,
IS_LOCAL BOOLEAN NOT NULL,
IS_PURE_REPOST BOOLEAN NOT NULL,
MEDIA_IDS VARCHAR(255) NOT NULL
);
CREATE TABLE IF NOT EXISTS USERS_FOLLOWERS
(
ID BIGSERIAL PRIMARY KEY,
USER_ID BIGINT NOT NULL,
FOLLOWER_ID BIGINT NOT NULL,
CONSTRAINT FK_USERS_FOLLOWERS_USER_ID__ID FOREIGN KEY (USER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT FK_USERS_FOLLOWERS_FOLLOWER_ID__ID FOREIGN KEY (FOLLOWER_ID) REFERENCES USERS (ID) ON DELETE RESTRICT ON UPDATE RESTRICT
);
CREATE TABLE IF NOT EXISTS APPLICATION_AUTHORIZATION
(
ID VARCHAR(255) PRIMARY KEY,
REGISTERED_CLIENT_ID VARCHAR(255) NOT NULL,
PRINCIPAL_NAME VARCHAR(255) NOT NULL,
AUTHORIZATION_GRANT_TYPE VARCHAR(255) NOT NULL,
AUTHORIZED_SCOPES VARCHAR(1000) DEFAULT NULL NULL,
"ATTRIBUTES" VARCHAR(4000) DEFAULT NULL NULL,
"STATE" VARCHAR(500) DEFAULT NULL NULL,
AUTHORIZATION_CODE_VALUE VARCHAR(4000) DEFAULT NULL NULL,
AUTHORIZATION_CODE_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
AUTHORIZATION_CODE_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
AUTHORIZATION_CODE_METADATA VARCHAR(2000) DEFAULT NULL NULL,
ACCESS_TOKEN_VALUE VARCHAR(4000) DEFAULT NULL NULL,
ACCESS_TOKEN_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
ACCESS_TOKEN_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
ACCESS_TOKEN_METADATA VARCHAR(2000) DEFAULT NULL NULL,
ACCESS_TOKEN_TYPE VARCHAR(255) DEFAULT NULL NULL,
ACCESS_TOKEN_SCOPES VARCHAR(1000) DEFAULT NULL NULL,
REFRESH_TOKEN_VALUE VARCHAR(4000) DEFAULT NULL NULL,
REFRESH_TOKEN_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
REFRESH_TOKEN_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
REFRESH_TOKEN_METADATA VARCHAR(2000) DEFAULT NULL NULL,
OIDC_ID_TOKEN_VALUE VARCHAR(4000) DEFAULT NULL NULL,
OIDC_ID_TOKEN_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
OIDC_ID_TOKEN_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
OIDC_ID_TOKEN_METADATA VARCHAR(2000) DEFAULT NULL NULL,
OIDC_ID_TOKEN_CLAIMS VARCHAR(2000) DEFAULT NULL NULL,
USER_CODE_VALUE VARCHAR(4000) DEFAULT NULL NULL,
USER_CODE_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
USER_CODE_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
USER_CODE_METADATA VARCHAR(2000) DEFAULT NULL NULL,
DEVICE_CODE_VALUE VARCHAR(4000) DEFAULT NULL NULL,
DEVICE_CODE_ISSUED_AT TIMESTAMP DEFAULT NULL NULL,
DEVICE_CODE_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
DEVICE_CODE_METADATA VARCHAR(2000) DEFAULT NULL NULL
);
CREATE TABLE IF NOT EXISTS OAUTH2_AUTHORIZATION_CONSENT
(
REGISTERED_CLIENT_ID VARCHAR(100),
PRINCIPAL_NAME VARCHAR(200),
AUTHORITIES VARCHAR(1000) NOT NULL,
CONSTRAINT pk_oauth2_authorization_consent PRIMARY KEY (REGISTERED_CLIENT_ID, PRINCIPAL_NAME)
);
CREATE TABLE IF NOT EXISTS REGISTERED_CLIENT
(
ID VARCHAR(100) PRIMARY KEY,
CLIENT_ID VARCHAR(100) NOT NULL,
CLIENT_ID_ISSUED_AT TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
CLIENT_SECRET VARCHAR(200) DEFAULT NULL NULL,
CLIENT_SECRET_EXPIRES_AT TIMESTAMP DEFAULT NULL NULL,
CLIENT_NAME VARCHAR(200) NOT NULL,
CLIENT_AUTHENTICATION_METHODS VARCHAR(1000) NOT NULL,
AUTHORIZATION_GRANT_TYPES VARCHAR(1000) NOT NULL,
REDIRECT_URIS VARCHAR(1000) DEFAULT NULL NULL,
POST_LOGOUT_REDIRECT_URIS VARCHAR(1000) DEFAULT NULL NULL,
SCOPES VARCHAR(1000) NOT NULL,
CLIENT_SETTINGS VARCHAR(2000) NOT NULL,
TOKEN_SETTINGS VARCHAR(2000) NOT NULL
)