]> git.openstreetmap.org Git - rails.git/commitdiff
Add a primary key to the changeset_tags table
authorTom Hughes <tom@compton.nu>
Sat, 7 Oct 2023 16:51:28 +0000 (17:51 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 8 Oct 2023 11:33:54 +0000 (12:33 +0100)
db/migrate/20231007141103_add_primary_key_to_changeset_tags.rb [new file with mode: 0644]
db/structure.sql

diff --git a/db/migrate/20231007141103_add_primary_key_to_changeset_tags.rb b/db/migrate/20231007141103_add_primary_key_to_changeset_tags.rb
new file mode 100644 (file)
index 0000000..6f01865
--- /dev/null
@@ -0,0 +1,13 @@
+class AddPrimaryKeyToChangesetTags < ActiveRecord::Migration[7.0]
+  disable_ddl_transaction!
+
+  def up
+    add_primary_key :changeset_tags, [:changeset_id, :k], :algorithm => :concurrently
+    remove_index :changeset_tags, [:changeset_id]
+  end
+
+  def down
+    add_index :changeset_tags, [:changeset_id], :algorithm => :concurrently
+    remove_primary_key :changeset_tags
+  end
+end
index bd65755f2bbbe40209908b4114bd730b91c82d46..939799c0a3509701f45d0b9d4d7bbb5b82d81eb6 100644 (file)
@@ -1838,6 +1838,14 @@ ALTER TABLE ONLY public.changeset_comments
     ADD CONSTRAINT changeset_comments_pkey PRIMARY KEY (id);
 
 
+--
+-- Name: changeset_tags changeset_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.changeset_tags
+    ADD CONSTRAINT changeset_tags_pkey PRIMARY KEY (changeset_id, k);
+
+
 --
 -- Name: changesets changesets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
@@ -2205,13 +2213,6 @@ ALTER TABLE ONLY public.ways
 CREATE INDEX acls_k_idx ON public.acls USING btree (k);
 
 
---
--- Name: changeset_tags_id_idx; Type: INDEX; Schema: public; Owner: -
---
-
-CREATE INDEX changeset_tags_id_idx ON public.changeset_tags USING btree (changeset_id);
-
-
 --
 -- Name: changesets_bbox_idx; Type: INDEX; Schema: public; Owner: -
 --
@@ -3466,6 +3467,7 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('20230825162137'),
 ('20230830115219'),
 ('20230830115220'),
+('20231007141103'),
 ('21'),
 ('22'),
 ('23'),