fix: トランザクションの問題をある程度解決

This commit is contained in:
usbharu 2023-11-21 17:03:12 +09:00
parent 3ac0782246
commit e71a1f74a3
3 changed files with 8 additions and 10 deletions

View File

@ -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 <T> transaction(block: suspend () -> T): T {
return newSuspendedTransaction(MDCContext(), transactionIsolation = Connection.TRANSACTION_SERIALIZABLE) {
return newSuspendedTransaction(MDCContext()) {
block()
}
}

View File

@ -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"

View File

@ -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;