Commit 55cdde01 authored by Rémy Coutable's avatar Rémy Coutable

[EE] Add `null: true` to timestamps in migrations that does not define it

This is to ensure that migrations will still be consitent when we will
upgrade to Rails 5 which default to `null: false` for timestamps
columns.

Fixes #23666.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 1c66e080
# rubocop:disable all # rubocop:disable all
class CreateForkedProjectLinks < ActiveRecord::Migration class CreateForkedProjectLinks < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :forked_project_links do |t| create_table :forked_project_links do |t|
t.integer :forked_to_project_id, null: false t.integer :forked_to_project_id, null: false
t.integer :forked_from_project_id, null: false t.integer :forked_from_project_id, null: false
t.timestamps t.timestamps null: true
end end
add_index :forked_project_links, :forked_to_project_id, unique: true add_index :forked_project_links, :forked_to_project_id, unique: true
end end
......
# rubocop:disable all # rubocop:disable all
class CreateDeployKeysProjects < ActiveRecord::Migration class CreateDeployKeysProjects < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :deploy_keys_projects do |t| create_table :deploy_keys_projects do |t|
t.integer :deploy_key_id, null: false t.integer :deploy_key_id, null: false
t.integer :project_id, null: false t.integer :project_id, null: false
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class CreateUsersGroups < ActiveRecord::Migration class CreateUsersGroups < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :users_groups do |t| create_table :users_groups do |t|
t.integer :group_access, null: false t.integer :group_access, null: false
t.integer :group_id, null: false t.integer :group_id, null: false
t.integer :user_id, null: false t.integer :user_id, null: false
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class CreateProjectGroupLinks < ActiveRecord::Migration class CreateProjectGroupLinks < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :project_group_links do |t| create_table :project_group_links do |t|
t.integer :project_id, null: false t.integer :project_id, null: false
t.integer :group_id, null: false t.integer :group_id, null: false
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class CreateBroadcastMessages < ActiveRecord::Migration class CreateBroadcastMessages < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :broadcast_messages do |t| create_table :broadcast_messages do |t|
t.text :message, null: false t.text :message, null: false
...@@ -7,7 +9,7 @@ class CreateBroadcastMessages < ActiveRecord::Migration ...@@ -7,7 +9,7 @@ class CreateBroadcastMessages < ActiveRecord::Migration
t.datetime :ends_at t.datetime :ends_at
t.integer :alert_type t.integer :alert_type
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class CreateMergeRequestDiffs < ActiveRecord::Migration class CreateMergeRequestDiffs < ActiveRecord::Migration
DOWNTIME = false
def up def up
create_table :merge_request_diffs do |t| create_table :merge_request_diffs do |t|
t.string :state, null: false, default: 'collected' t.string :state, null: false, default: 'collected'
...@@ -7,7 +9,7 @@ class CreateMergeRequestDiffs < ActiveRecord::Migration ...@@ -7,7 +9,7 @@ class CreateMergeRequestDiffs < ActiveRecord::Migration
t.text :st_diffs, null: true t.text :st_diffs, null: true
t.integer :merge_request_id, null: false t.integer :merge_request_id, null: false
t.timestamps t.timestamps null: true
end end
if ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ if ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/
......
# rubocop:disable all # rubocop:disable all
class CreateEmails < ActiveRecord::Migration class CreateEmails < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :emails do |t| create_table :emails do |t|
t.integer :user_id, null: false t.integer :user_id, null: false
t.string :email, null: false t.string :email, null: false
t.timestamps t.timestamps null: true
end end
add_index :emails, :user_id add_index :emails, :user_id
......
class CreateGitHooks < ActiveRecord::Migration class CreateGitHooks < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :git_hooks do |t| create_table :git_hooks do |t|
t.string :force_push_regex t.string :force_push_regex
...@@ -7,7 +9,7 @@ class CreateGitHooks < ActiveRecord::Migration ...@@ -7,7 +9,7 @@ class CreateGitHooks < ActiveRecord::Migration
t.boolean :deny_delete_tag t.boolean :deny_delete_tag
t.integer :project_id t.integer :project_id
t.timestamps t.timestamps null: true
end end
end end
end end
class CreateAppearances < ActiveRecord::Migration class CreateAppearances < ActiveRecord::Migration
DOWNTIME = false
def change def change
# GitLab CE may already have created this table, so to preserve # GitLab CE may already have created this table, so to preserve
# the upgrade path from CE -> EE we only create this if necessary. # the upgrade path from CE -> EE we only create this if necessary.
...@@ -9,7 +11,7 @@ class CreateAppearances < ActiveRecord::Migration ...@@ -9,7 +11,7 @@ class CreateAppearances < ActiveRecord::Migration
t.string :logo t.string :logo
t.integer :updated_by t.integer :updated_by
t.timestamps t.timestamps null: true
end end
end end
end end
......
# rubocop:disable all # rubocop:disable all
class CreateUsersStarProjects < ActiveRecord::Migration class CreateUsersStarProjects < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :users_star_projects do |t| create_table :users_star_projects do |t|
t.integer :project_id, null: false t.integer :project_id, null: false
t.integer :user_id, null: false t.integer :user_id, null: false
t.timestamps t.timestamps null: true
end end
add_index :users_star_projects, :user_id add_index :users_star_projects, :user_id
add_index :users_star_projects, :project_id add_index :users_star_projects, :project_id
......
# rubocop:disable all # rubocop:disable all
class CreateLabels < ActiveRecord::Migration class CreateLabels < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :labels do |t| create_table :labels do |t|
t.string :title t.string :title
t.string :color t.string :color
t.integer :project_id t.integer :project_id
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class CreateLabelLinks < ActiveRecord::Migration class CreateLabelLinks < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :label_links do |t| create_table :label_links do |t|
t.integer :label_id t.integer :label_id
t.integer :target_id t.integer :target_id
t.string :target_type t.string :target_type
t.timestamps t.timestamps null: true
end end
end end
end end
class AddLdapGroupsTable < ActiveRecord::Migration class AddLdapGroupsTable < ActiveRecord::Migration
DOWNTIME = false
def up def up
create_table :ldap_groups do |t| create_table :ldap_groups do |t|
t.string :cn, null: false t.string :cn, null: false
t.integer :group_access, null: false t.integer :group_access, null: false
t.references :group, null: false t.references :group, null: false
t.timestamps t.timestamps null: true
end end
end end
......
# rubocop:disable all # rubocop:disable all
class AddMembersTable < ActiveRecord::Migration class AddMembersTable < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :members do |t| create_table :members do |t|
t.integer :access_level, null: false t.integer :access_level, null: false
...@@ -9,7 +11,7 @@ class AddMembersTable < ActiveRecord::Migration ...@@ -9,7 +11,7 @@ class AddMembersTable < ActiveRecord::Migration
t.integer :notification_level, null: false t.integer :notification_level, null: false
t.string :type t.string :type
t.timestamps t.timestamps null: true
end end
add_index :members, :type add_index :members, :type
......
# rubocop:disable all # rubocop:disable all
class RemoveOldMemberTables < ActiveRecord::Migration class RemoveOldMemberTables < ActiveRecord::Migration
DOWNTIME = false
def up def up
drop_table :users_groups drop_table :users_groups
drop_table :users_projects drop_table :users_projects
...@@ -12,7 +14,7 @@ class RemoveOldMemberTables < ActiveRecord::Migration ...@@ -12,7 +14,7 @@ class RemoveOldMemberTables < ActiveRecord::Migration
t.integer :user_id, null: false t.integer :user_id, null: false
t.integer :notification_level, null: false, default: 3 t.integer :notification_level, null: false, default: 3
t.timestamps t.timestamps null: true
end end
create_table :users_projects do |t| create_table :users_projects do |t|
...@@ -21,7 +23,7 @@ class RemoveOldMemberTables < ActiveRecord::Migration ...@@ -21,7 +23,7 @@ class RemoveOldMemberTables < ActiveRecord::Migration
t.integer :user_id, null: false t.integer :user_id, null: false
t.integer :notification_level, null: false, default: 3 t.integer :notification_level, null: false, default: 3
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class AddAuditEvent < ActiveRecord::Migration class AddAuditEvent < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :audit_events do |t| create_table :audit_events do |t|
t.integer :author_id, null: false t.integer :author_id, null: false
...@@ -13,7 +15,7 @@ class AddAuditEvent < ActiveRecord::Migration ...@@ -13,7 +15,7 @@ class AddAuditEvent < ActiveRecord::Migration
# Details for the event # Details for the event
t.text :details t.text :details
t.timestamps t.timestamps null: true
end end
add_index :audit_events, :author_id add_index :audit_events, :author_id
......
# rubocop:disable all # rubocop:disable all
class CreateDoorkeeperTables < ActiveRecord::Migration class CreateDoorkeeperTables < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :oauth_applications do |t| create_table :oauth_applications do |t|
t.string :name, null: false t.string :name, null: false
...@@ -7,7 +9,7 @@ class CreateDoorkeeperTables < ActiveRecord::Migration ...@@ -7,7 +9,7 @@ class CreateDoorkeeperTables < ActiveRecord::Migration
t.string :secret, null: false t.string :secret, null: false
t.text :redirect_uri, null: false t.text :redirect_uri, null: false
t.string :scopes, null: false, default: '' t.string :scopes, null: false, default: ''
t.timestamps t.timestamps null: true
end end
add_index :oauth_applications, :uid, unique: true add_index :oauth_applications, :uid, unique: true
......
# rubocop:disable all # rubocop:disable all
class CreateApplicationSettings < ActiveRecord::Migration class CreateApplicationSettings < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :application_settings do |t| create_table :application_settings do |t|
t.integer :default_projects_limit t.integer :default_projects_limit
...@@ -8,7 +10,7 @@ class CreateApplicationSettings < ActiveRecord::Migration ...@@ -8,7 +10,7 @@ class CreateApplicationSettings < ActiveRecord::Migration
t.boolean :gravatar_enabled t.boolean :gravatar_enabled
t.text :sign_in_text t.text :sign_in_text
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class CreateSubscriptionsTable < ActiveRecord::Migration class CreateSubscriptionsTable < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :subscriptions do |t| create_table :subscriptions do |t|
t.integer :user_id t.integer :user_id
t.references :subscribable, polymorphic: true t.references :subscribable, polymorphic: true
t.boolean :subscribed t.boolean :subscribed
t.timestamps t.timestamps null: true
end end
add_index :subscriptions, add_index :subscriptions,
......
class CreateLicenses < ActiveRecord::Migration class CreateLicenses < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :licenses do |t| create_table :licenses do |t|
t.text :data, null: false t.text :data, null: false
t.timestamps t.timestamps null: true
end end
end end
end end
class CreateHistoricalData < ActiveRecord::Migration class CreateHistoricalData < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :historical_data do |t| create_table :historical_data do |t|
t.date :date, null: false t.date :date, null: false
t.integer :active_user_count t.integer :active_user_count
t.timestamps t.timestamps null: true
end end
end end
end end
class CreateApproves < ActiveRecord::Migration class CreateApproves < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :approvals do |t| create_table :approvals do |t|
t.integer :merge_request_id, null: false t.integer :merge_request_id, null: false
t.integer :user_id, null: false t.integer :user_id, null: false
t.timestamps t.timestamps null: true
end end
end end
end end
class AddApproversTable < ActiveRecord::Migration class AddApproversTable < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :approvers do |t| create_table :approvers do |t|
t.integer :target_id, null: false t.integer :target_id, null: false
t.string :target_type t.string :target_type
t.integer :user_id, null: false t.integer :user_id, null: false
t.timestamps t.timestamps null: true
t.index [:target_id, :target_type] t.index [:target_id, :target_type]
t.index :user_id t.index :user_id
......
# rubocop:disable all # rubocop:disable all
class CreateAbuseReports < ActiveRecord::Migration class CreateAbuseReports < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :abuse_reports do |t| create_table :abuse_reports do |t|
t.integer :reporter_id t.integer :reporter_id
t.integer :user_id t.integer :user_id
t.text :message t.text :message
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class CreateLfsObjects < ActiveRecord::Migration class CreateLfsObjects < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :lfs_objects do |t| create_table :lfs_objects do |t|
t.string :oid, null: false, unique: true t.string :oid, null: false, unique: true
t.integer :size, null: false t.integer :size, null: false
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class CreateLfsObjectsProjects < ActiveRecord::Migration class CreateLfsObjectsProjects < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :lfs_objects_projects do |t| create_table :lfs_objects_projects do |t|
t.integer :lfs_object_id, null: false t.integer :lfs_object_id, null: false
t.integer :project_id, null: false t.integer :project_id, null: false
t.timestamps t.timestamps null: true
end end
add_index :lfs_objects_projects, :project_id add_index :lfs_objects_projects, :project_id
......
# rubocop:disable all # rubocop:disable all
class CreateReleases < ActiveRecord::Migration class CreateReleases < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :releases do |t| create_table :releases do |t|
t.string :tag t.string :tag
t.text :description t.text :description
t.integer :project_id t.integer :project_id
t.timestamps t.timestamps null: true
end end
add_index :releases, :project_id add_index :releases, :project_id
......
# rubocop:disable all # rubocop:disable all
class CreateTasks < ActiveRecord::Migration class CreateTasks < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :tasks do |t| create_table :tasks do |t|
t.references :user, null: false, index: true t.references :user, null: false, index: true
...@@ -9,7 +11,7 @@ class CreateTasks < ActiveRecord::Migration ...@@ -9,7 +11,7 @@ class CreateTasks < ActiveRecord::Migration
t.integer :action, null: false t.integer :action, null: false
t.string :state, null: false, index: true t.string :state, null: false, index: true
t.timestamps t.timestamps null: true
end end
end end
end end
# rubocop:disable all # rubocop:disable all
class AddAwardEmoji < ActiveRecord::Migration class AddAwardEmoji < ActiveRecord::Migration
DOWNTIME = false
def change def change
create_table :award_emoji do |t| create_table :award_emoji do |t|
t.string :name t.string :name
t.references :user t.references :user
t.references :awardable, polymorphic: true t.references :awardable, polymorphic: true
t.timestamps t.timestamps null: true
end end
add_index :award_emoji, :user_id add_index :award_emoji, :user_id
......
...@@ -10,7 +10,7 @@ class CreateProjectFeatures < ActiveRecord::Migration ...@@ -10,7 +10,7 @@ class CreateProjectFeatures < ActiveRecord::Migration
t.integer :snippets_access_level t.integer :snippets_access_level
t.integer :builds_access_level t.integer :builds_access_level
t.timestamps t.timestamps null: true
end end
end end
end end
...@@ -14,7 +14,7 @@ class AddApproverGroups < ActiveRecord::Migration ...@@ -14,7 +14,7 @@ class AddApproverGroups < ActiveRecord::Migration
t.string :target_type, null: false t.string :target_type, null: false
t.integer :group_id, null: false t.integer :group_id, null: false
t.timestamps t.timestamps null: true
t.index [:target_id, :target_type] t.index [:target_id, :target_type]
t.index :group_id t.index :group_id
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment