mirror of https://github.com/usbharu/Hideout.git
fix: トランザクションの問題をある程度解決
This commit is contained in:
parent
3ac0782246
commit
e71a1f74a3
|
@ -4,12 +4,11 @@ import dev.usbharu.hideout.application.external.Transaction
|
||||||
import kotlinx.coroutines.slf4j.MDCContext
|
import kotlinx.coroutines.slf4j.MDCContext
|
||||||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.sql.Connection
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ExposedTransaction : Transaction {
|
class ExposedTransaction : Transaction {
|
||||||
override suspend fun <T> transaction(block: suspend () -> T): T {
|
override suspend fun <T> transaction(block: suspend () -> T): T {
|
||||||
return newSuspendedTransaction(MDCContext(), transactionIsolation = Connection.TRANSACTION_SERIALIZABLE) {
|
return newSuspendedTransaction(MDCContext()) {
|
||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ spring:
|
||||||
WRITE_DATES_AS_TIMESTAMPS: false
|
WRITE_DATES_AS_TIMESTAMPS: false
|
||||||
default-property-inclusion: always
|
default-property-inclusion: always
|
||||||
datasource:
|
datasource:
|
||||||
hikari:
|
|
||||||
transaction-isolation: "TRANSACTION_SERIALIZABLE"
|
|
||||||
driver-class-name: org.postgresql.Driver
|
driver-class-name: org.postgresql.Driver
|
||||||
url: "jdbc:postgresql:hideout2"
|
url: "jdbc:postgresql:hideout2"
|
||||||
username: "postgres"
|
username: "postgres"
|
||||||
|
|
|
@ -3,9 +3,9 @@ create table if not exists instance
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
"name" varchar(1000) not null,
|
"name" varchar(1000) not null,
|
||||||
description varchar(5000) not null,
|
description varchar(5000) not null,
|
||||||
url varchar(255) not null,
|
url varchar(255) not null unique,
|
||||||
icon_url varchar(255) not null,
|
icon_url varchar(255) not null,
|
||||||
shared_inbox varchar(255) null,
|
shared_inbox varchar(255) null unique,
|
||||||
software varchar(255) not null,
|
software varchar(255) not null,
|
||||||
version varchar(255) not null,
|
version varchar(255) not null,
|
||||||
is_blocked boolean not null,
|
is_blocked boolean not null,
|
||||||
|
@ -21,9 +21,9 @@ create table if not exists users
|
||||||
screen_name varchar(300) not null,
|
screen_name varchar(300) not null,
|
||||||
description varchar(10000) not null,
|
description varchar(10000) not null,
|
||||||
password varchar(255) null,
|
password varchar(255) null,
|
||||||
inbox varchar(1000) not null,
|
inbox varchar(1000) not null unique,
|
||||||
outbox varchar(1000) not null,
|
outbox varchar(1000) not null unique,
|
||||||
url varchar(1000) not null,
|
url varchar(1000) not null unique,
|
||||||
public_key varchar(10000) not null,
|
public_key varchar(10000) not null,
|
||||||
private_key varchar(10000) null,
|
private_key varchar(10000) null,
|
||||||
created_at bigint not null,
|
created_at bigint not null,
|
||||||
|
@ -31,6 +31,7 @@ create table if not exists users
|
||||||
"following" varchar(1000) null,
|
"following" varchar(1000) null,
|
||||||
followers varchar(1000) null,
|
followers varchar(1000) null,
|
||||||
"instance" bigint null,
|
"instance" bigint null,
|
||||||
|
unique (name, domain),
|
||||||
constraint fk_users_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict
|
constraint fk_users_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict
|
||||||
);
|
);
|
||||||
create table if not exists follow_requests
|
create table if not exists follow_requests
|
||||||
|
@ -73,7 +74,7 @@ create table if not exists posts
|
||||||
repost_id bigint null,
|
repost_id bigint null,
|
||||||
reply_id bigint null,
|
reply_id bigint null,
|
||||||
"sensitive" boolean default false not null,
|
"sensitive" boolean default false not null,
|
||||||
ap_id varchar(100) not null
|
ap_id varchar(100) not null unique
|
||||||
);
|
);
|
||||||
alter table posts
|
alter table posts
|
||||||
add constraint fk_posts_userid__id foreign key (user_id) references users (id) on delete restrict on update restrict;
|
add constraint fk_posts_userid__id foreign key (user_id) references users (id) on delete restrict on update restrict;
|
||||||
|
|
Loading…
Reference in New Issue