]> git.openstreetmap.org Git - rails.git/commitdiff
Combine migrations into one
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 29 Nov 2017 16:12:38 +0000 (16:12 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 29 Nov 2017 16:13:32 +0000 (16:13 +0000)
This makes it easier to review, rather than having a PR with migrations that
correct each other.

app/models/issue.rb
db/migrate/20160822153055_create_issues_and_reports.rb
db/migrate/20160822153115_create_issue_comments.rb [deleted file]
db/migrate/20160822153153_add_reports_count_to_issues.rb [deleted file]
db/structure.sql

index 567ee819e30e99b011b6db6d01a09a387c631bfa..a08bfd6a4ca642d45130ab4ab35b0adf83e6914a 100644 (file)
@@ -11,9 +11,9 @@
 #  resolved_at      :datetime
 #  resolved_by      :integer
 #  updated_by       :integer
 #  resolved_at      :datetime
 #  resolved_by      :integer
 #  updated_by       :integer
+#  reports_count    :integer          default(0)
 #  created_at       :datetime         not null
 #  updated_at       :datetime         not null
 #  created_at       :datetime         not null
 #  updated_at       :datetime         not null
-#  reports_count    :integer          default(0)
 #
 # Indexes
 #
 #
 # Indexes
 #
index 5a7020e6ed8178c2f28d42aea55b40de01aab12a..a66b22d25394e100355dcffc7ecfcf561c7ae6b2 100644 (file)
@@ -9,13 +9,16 @@ class CreateIssuesAndReports < ActiveRecord::Migration[5.0]
       t.datetime :resolved_at
       t.integer :resolved_by
       t.integer :updated_by
       t.datetime :resolved_at
       t.integer :resolved_by
       t.integer :updated_by
+      t.integer :reports_count, :default => 0
       t.timestamps :null => false
     end
 
     add_foreign_key :issues, :users, :column => :reported_user_id, :name => "issues_reported_user_id_fkey", :on_delete => :cascade
       t.timestamps :null => false
     end
 
     add_foreign_key :issues, :users, :column => :reported_user_id, :name => "issues_reported_user_id_fkey", :on_delete => :cascade
+    add_foreign_key :issues, :users, :column => :updated_by, :name => "issues_updated_by_fkey", :on_delete => :cascade
 
     add_index :issues, :reported_user_id
     add_index :issues, [:reportable_id, :reportable_type]
 
     add_index :issues, :reported_user_id
     add_index :issues, [:reportable_id, :reportable_type]
+    add_index :issues, :updated_by
 
     create_table :reports do |t|
       t.integer :issue_id
 
     create_table :reports do |t|
       t.integer :issue_id
@@ -29,5 +32,18 @@ class CreateIssuesAndReports < ActiveRecord::Migration[5.0]
 
     add_index :reports, :reporter_user_id
     add_index :reports, :issue_id
 
     add_index :reports, :reporter_user_id
     add_index :reports, :issue_id
+
+    create_table :issue_comments do |t|
+      t.integer :issue_id, :null => false
+      t.integer :commenter_user_id, :null => false
+      t.text :body, :null => false
+      t.timestamps :null => false
+    end
+
+    add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey", :on_delete => :cascade
+    add_foreign_key :issue_comments, :users, :column => :commenter_user_id, :name => "issue_comments_commenter_user_id", :on_delete => :cascade
+
+    add_index :issue_comments, :commenter_user_id
+    add_index :issue_comments, :issue_id
   end
 end
   end
 end
diff --git a/db/migrate/20160822153115_create_issue_comments.rb b/db/migrate/20160822153115_create_issue_comments.rb
deleted file mode 100644 (file)
index 73aab9a..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-class CreateIssueComments < ActiveRecord::Migration[5.0]
-  def change
-    create_table :issue_comments do |t|
-      t.integer :issue_id, :null => false
-      t.integer :commenter_user_id, :null => false
-      t.text :body, :null => false
-      t.timestamps :null => false
-    end
-
-    add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey", :on_delete => :cascade
-    add_foreign_key :issue_comments, :users, :column => :commenter_user_id, :name => "issue_comments_commenter_user_id", :on_delete => :cascade
-
-    add_index :issue_comments, :commenter_user_id
-    add_index :issue_comments, :issue_id
-  end
-end
diff --git a/db/migrate/20160822153153_add_reports_count_to_issues.rb b/db/migrate/20160822153153_add_reports_count_to_issues.rb
deleted file mode 100644 (file)
index e435f4f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-class AddReportsCountToIssues < ActiveRecord::Migration[5.0]
-  def change
-    add_column :issues, :reports_count, :integer, :default => 0
-    add_foreign_key :issues, :users, :column => :updated_by, :name => "issues_updated_by_fkey", :on_delete => :cascade
-    add_index :issues, :updated_by
-  end
-end
index 83257318313d623d21540137cde83bf60ca64170..a4a6ff6c728fbf1e0dd5bd50c05e33f04e9f7ecf 100644 (file)
@@ -732,9 +732,9 @@ CREATE TABLE issues (
     resolved_at timestamp without time zone,
     resolved_by integer,
     updated_by integer,
     resolved_at timestamp without time zone,
     resolved_by integer,
     updated_by integer,
+    reports_count integer DEFAULT 0,
     created_at timestamp without time zone NOT NULL,
     created_at timestamp without time zone NOT NULL,
-    updated_at timestamp without time zone NOT NULL,
-    reports_count integer DEFAULT 0
+    updated_at timestamp without time zone NOT NULL
 );
 
 
 );
 
 
@@ -1066,7 +1066,7 @@ CREATE TABLE reports (
     id integer NOT NULL,
     issue_id integer,
     reporter_user_id integer,
     id integer NOT NULL,
     issue_id integer,
     reporter_user_id integer,
-    details text,
+    details text NOT NULL,
     created_at timestamp without time zone NOT NULL,
     updated_at timestamp without time zone NOT NULL
 );
     created_at timestamp without time zone NOT NULL,
     updated_at timestamp without time zone NOT NULL
 );
@@ -2830,8 +2830,6 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('20150222101847'),
 ('20150818224516'),
 ('20160822153055'),
 ('20150222101847'),
 ('20150818224516'),
 ('20160822153055'),
-('20160822153115'),
-('20160822153153'),
 ('20161002153425'),
 ('20161011010929'),
 ('20170222134109'),
 ('20161002153425'),
 ('20161011010929'),
 ('20170222134109'),