aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/db/specific
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-24 04:57:28 +0300
committerGravatar Vitaly Takmazov2022-12-24 04:57:28 +0300
commit0ab02be35b4f83a10c1d586c7e069b9e1dc4c075 (patch)
tree3549a906493a17bbf91d489ff6c2083f28fae1d8 /src/main/resources/db/specific
parent36ebeb217326c6bc23dedfde1e028ae2286afe02 (diff)
db: cleanup duplicated followers and add constraints
Diffstat (limited to 'src/main/resources/db/specific')
-rw-r--r--src/main/resources/db/specific/h2/V1.27__followers_unique.sql1
-rw-r--r--src/main/resources/db/specific/mariadb/V1.27__followers_unique.sql1
-rw-r--r--src/main/resources/db/specific/postgresql/V1.27__followers_unique.sql4
3 files changed, 6 insertions, 0 deletions
diff --git a/src/main/resources/db/specific/h2/V1.27__followers_unique.sql b/src/main/resources/db/specific/h2/V1.27__followers_unique.sql
new file mode 100644
index 00000000..e103d1a0
--- /dev/null
+++ b/src/main/resources/db/specific/h2/V1.27__followers_unique.sql
@@ -0,0 +1 @@
+ALTER TABLE followers ADD UNIQUE (user_id, acct) \ No newline at end of file
diff --git a/src/main/resources/db/specific/mariadb/V1.27__followers_unique.sql b/src/main/resources/db/specific/mariadb/V1.27__followers_unique.sql
new file mode 100644
index 00000000..e103d1a0
--- /dev/null
+++ b/src/main/resources/db/specific/mariadb/V1.27__followers_unique.sql
@@ -0,0 +1 @@
+ALTER TABLE followers ADD UNIQUE (user_id, acct) \ No newline at end of file
diff --git a/src/main/resources/db/specific/postgresql/V1.27__followers_unique.sql b/src/main/resources/db/specific/postgresql/V1.27__followers_unique.sql
new file mode 100644
index 00000000..5a15d9ae
--- /dev/null
+++ b/src/main/resources/db/specific/postgresql/V1.27__followers_unique.sql
@@ -0,0 +1,4 @@
+DELETE
+FROM followers A USING followers B
+WHERE A.user_id=B.user_id AND A.ts<=B.ts AND A.acct=B.acct AND A.ctid<B.ctid;
+ALTER TABLE followers ADD UNIQUE (user_id, acct) \ No newline at end of file