about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200215014558_add_hidden_to_statuses.rb5
-rw-r--r--db/migrate/20200215020121_add_index_unhidden_to_statuses.rb7
-rw-r--r--db/migrate/20200215021014_set_null_constraint_on_statuses_hidden.rb7
-rw-r--r--db/migrate/20200215021730_set_default_unhidden_on_statuses.rb8
-rw-r--r--db/migrate/20200215021731_validate_set_default_unhidden_on_statuses.rb7
-rw-r--r--db/structure.sql18
6 files changed, 49 insertions, 3 deletions
diff --git a/db/migrate/20200215014558_add_hidden_to_statuses.rb b/db/migrate/20200215014558_add_hidden_to_statuses.rb
new file mode 100644
index 000000000..886a2f7c4
--- /dev/null
+++ b/db/migrate/20200215014558_add_hidden_to_statuses.rb
@@ -0,0 +1,5 @@
+class AddHiddenToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    add_column :statuses, :hidden, :boolean
+  end
+end
diff --git a/db/migrate/20200215020121_add_index_unhidden_to_statuses.rb b/db/migrate/20200215020121_add_index_unhidden_to_statuses.rb
new file mode 100644
index 000000000..17f936a00
--- /dev/null
+++ b/db/migrate/20200215020121_add_index_unhidden_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddIndexUnhiddenToStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_index :statuses, [:account_id, :id, :visibility], where: 'NOT hidden', algorithm: :concurrently, name: 'index_statuses_on_account_id_and_id_and_visibility_not_hidden'
+  end
+end
diff --git a/db/migrate/20200215021014_set_null_constraint_on_statuses_hidden.rb b/db/migrate/20200215021014_set_null_constraint_on_statuses_hidden.rb
new file mode 100644
index 000000000..70b3a764c
--- /dev/null
+++ b/db/migrate/20200215021014_set_null_constraint_on_statuses_hidden.rb
@@ -0,0 +1,7 @@
+class SetNullConstraintOnStatusesHidden < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      execute 'ALTER TABLE "statuses" ADD CONSTRAINT "statuses_hidden_null" CHECK ("hidden" IS NOT NULL) NOT VALID'
+    end
+  end
+end
diff --git a/db/migrate/20200215021730_set_default_unhidden_on_statuses.rb b/db/migrate/20200215021730_set_default_unhidden_on_statuses.rb
new file mode 100644
index 000000000..1d239d110
--- /dev/null
+++ b/db/migrate/20200215021730_set_default_unhidden_on_statuses.rb
@@ -0,0 +1,8 @@
+class SetDefaultUnhiddenOnStatuses < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      change_column_default :statuses, :hidden, false
+      Status.in_batches.update_all(hidden: false)
+    end
+  end
+end
diff --git a/db/migrate/20200215021731_validate_set_default_unhidden_on_statuses.rb b/db/migrate/20200215021731_validate_set_default_unhidden_on_statuses.rb
new file mode 100644
index 000000000..b87b61dcc
--- /dev/null
+++ b/db/migrate/20200215021731_validate_set_default_unhidden_on_statuses.rb
@@ -0,0 +1,7 @@
+class ValidateSetDefaultUnhiddenOnStatuses < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      execute 'ALTER TABLE "statuses" VALIDATE CONSTRAINT "statuses_hidden_null"'
+    end
+  end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 264fa7111..d0f9eb481 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -800,7 +800,8 @@ CREATE TABLE public.conversations (
     id bigint NOT NULL,
     uri character varying,
     created_at timestamp without time zone NOT NULL,
-    updated_at timestamp without time zone NOT NULL
+    updated_at timestamp without time zone NOT NULL,
+    limit_replies smallint
 );
 
 
@@ -2223,7 +2224,8 @@ CREATE TABLE public.statuses (
     edited boolean,
     boostable boolean,
     reject_replies boolean,
-    tsv tsvector GENERATED ALWAYS AS (to_tsvector('public.fedi'::regconfig, public.f_strip_mentions(((spoiler_text || ' '::text) || text)))) STORED
+    tsv tsvector GENERATED ALWAYS AS (to_tsvector('public.fedi'::regconfig, public.f_strip_mentions(((spoiler_text || ' '::text) || text)))) STORED,
+    hidden boolean
 );
 
 
@@ -4185,6 +4187,13 @@ CREATE INDEX index_statuses_on_account_id_and_id_and_visibility ON public.status
 
 
 --
+-- Name: index_statuses_on_account_id_and_id_and_visibility_not_hidden; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_statuses_on_account_id_and_id_and_visibility_not_hidden ON public.statuses USING btree (account_id, id, visibility) WHERE (NOT hidden);
+
+
+--
 -- Name: index_statuses_on_in_reply_to_account_id; Type: INDEX; Schema: public; Owner: -
 --
 
@@ -5403,6 +5412,9 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('20200111042543'),
 ('20200114011918'),
 ('20200114030940'),
-('20200115201524');
+('20200115201524'),
+('20200205194250'),
+('20200215014558'),
+('20200215020121');