summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb24
-rw-r--r--db/schema.rb4
2 files changed, 26 insertions, 2 deletions
diff --git a/db/migrate/20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb b/db/migrate/20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb
new file mode 100644
index 00000000000..f8f1c6c231b
--- /dev/null
+++ b/db/migrate/20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class BackfillReleasesTableUpdatedAtAndAddNotNullConstraintsToTimestamps < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ change_column_null(:releases, :created_at, false, Time.zone.now)
+
+ update_column_in_batches(:releases, :updated_at, Arel.sql('created_at')) do |table, query|
+ query.where(table[:updated_at].eq(nil))
+ end
+
+ change_column_null(:releases, :updated_at, false, Time.zone.now)
+ end
+
+ def down
+ change_column_null(:releases, :updated_at, true)
+ change_column_null(:releases, :created_at, true)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index be774169517..ef52143da73 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -3137,8 +3137,8 @@ ActiveRecord::Schema.define(version: 2019_09_27_074328) do
t.string "tag"
t.text "description"
t.integer "project_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.text "description_html"
t.integer "cached_markdown_version"
t.integer "author_id"