From e71a1f74a33c81d3846115fa372cd51fb08dd566 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Tue, 21 Nov 2023 17:03:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=88=E3=83=A9=E3=83=B3=E3=82=B6?= =?UTF-8?q?=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AE=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E3=81=82=E3=82=8B=E7=A8=8B=E5=BA=A6=E8=A7=A3=E6=B1=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/exposed/ExposedTransaction.kt | 3 +-- src/main/resources/application.yml | 2 -- src/main/resources/db/migration/V1__Init_DB.sql | 13 +++++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/application/infrastructure/exposed/ExposedTransaction.kt b/src/main/kotlin/dev/usbharu/hideout/application/infrastructure/exposed/ExposedTransaction.kt index 4dc8316b..3438d428 100644 --- a/src/main/kotlin/dev/usbharu/hideout/application/infrastructure/exposed/ExposedTransaction.kt +++ b/src/main/kotlin/dev/usbharu/hideout/application/infrastructure/exposed/ExposedTransaction.kt @@ -4,12 +4,11 @@ import dev.usbharu.hideout.application.external.Transaction import kotlinx.coroutines.slf4j.MDCContext import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction import org.springframework.stereotype.Service -import java.sql.Connection @Service class ExposedTransaction : Transaction { override suspend fun transaction(block: suspend () -> T): T { - return newSuspendedTransaction(MDCContext(), transactionIsolation = Connection.TRANSACTION_SERIALIZABLE) { + return newSuspendedTransaction(MDCContext()) { block() } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c9c2604f..daff34db 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -18,8 +18,6 @@ spring: WRITE_DATES_AS_TIMESTAMPS: false default-property-inclusion: always datasource: - hikari: - transaction-isolation: "TRANSACTION_SERIALIZABLE" driver-class-name: org.postgresql.Driver url: "jdbc:postgresql:hideout2" username: "postgres" diff --git a/src/main/resources/db/migration/V1__Init_DB.sql b/src/main/resources/db/migration/V1__Init_DB.sql index 15a61994..4ea80255 100644 --- a/src/main/resources/db/migration/V1__Init_DB.sql +++ b/src/main/resources/db/migration/V1__Init_DB.sql @@ -3,9 +3,9 @@ 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, + url varchar(255) not null unique, icon_url varchar(255) not null, - shared_inbox varchar(255) null, + shared_inbox varchar(255) null unique, software varchar(255) not null, version varchar(255) not null, is_blocked boolean not null, @@ -21,9 +21,9 @@ create table if not exists users 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, + inbox varchar(1000) not null unique, + outbox varchar(1000) not null unique, + url varchar(1000) not null unique, public_key varchar(10000) not null, private_key varchar(10000) null, created_at bigint not null, @@ -31,6 +31,7 @@ create table if not exists users "following" varchar(1000) null, followers varchar(1000) null, "instance" bigint null, + unique (name, domain), constraint fk_users_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict ); create table if not exists follow_requests @@ -73,7 +74,7 @@ create table if not exists posts repost_id bigint null, reply_id bigint null, "sensitive" boolean default false not null, - ap_id varchar(100) not null + ap_id varchar(100) not null unique ); alter table posts add constraint fk_posts_userid__id foreign key (user_id) references users (id) on delete restrict on update restrict;