diff options
Diffstat (limited to 'db/migrate')
7 files changed, 87 insertions, 1 deletions
diff --git a/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb b/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb new file mode 100644 index 00000000000..a7f76cc626e --- /dev/null +++ b/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb @@ -0,0 +1,9 @@ +class AddUsagePingToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :application_settings, :usage_ping_enabled, :boolean, default: true, null: false + end +end diff --git a/db/migrate/20161007073613_create_user_activities.rb b/db/migrate/20161007073613_create_user_activities.rb new file mode 100644 index 00000000000..1d694e777a1 --- /dev/null +++ b/db/migrate/20161007073613_create_user_activities.rb @@ -0,0 +1,7 @@ +class CreateUserActivities < ActiveRecord::Migration + DOWNTIME = false + + # This migration is a no-op. It just exists to match EE. + def change + end +end diff --git a/db/migrate/20170307125949_add_last_activity_on_to_users.rb b/db/migrate/20170307125949_add_last_activity_on_to_users.rb new file mode 100644 index 00000000000..0100836b473 --- /dev/null +++ b/db/migrate/20170307125949_add_last_activity_on_to_users.rb @@ -0,0 +1,9 @@ +class AddLastActivityOnToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :users, :last_activity_on, :date + end +end diff --git a/db/migrate/20170328010804_add_uuid_to_application_settings.rb b/db/migrate/20170328010804_add_uuid_to_application_settings.rb new file mode 100644 index 00000000000..5dfcc751c7b --- /dev/null +++ b/db/migrate/20170328010804_add_uuid_to_application_settings.rb @@ -0,0 +1,16 @@ +class AddUuidToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column :application_settings, :uuid, :string + execute("UPDATE application_settings SET uuid = #{quote(SecureRandom.uuid)}") + end + + def down + remove_column :application_settings, :uuid + end +end diff --git a/db/migrate/20170413035209_add_preferred_language_to_users.rb b/db/migrate/20170413035209_add_preferred_language_to_users.rb index 5dc128dbaea..6fe91656eeb 100644 --- a/db/migrate/20170413035209_add_preferred_language_to_users.rb +++ b/db/migrate/20170413035209_add_preferred_language_to_users.rb @@ -8,7 +8,11 @@ class AddPreferredLanguageToUsers < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_column_with_default :users, :preferred_language, :string, default: 'en' end + + def down + remove_column :users, :preferred_language + end end diff --git a/db/migrate/20170418103908_delete_orphan_notification_settings.rb b/db/migrate/20170418103908_delete_orphan_notification_settings.rb new file mode 100644 index 00000000000..e4b9cf65936 --- /dev/null +++ b/db/migrate/20170418103908_delete_orphan_notification_settings.rb @@ -0,0 +1,24 @@ +class DeleteOrphanNotificationSettings < ActiveRecord::Migration + DOWNTIME = false + + def up + execute("DELETE FROM notification_settings WHERE EXISTS (SELECT true FROM (#{orphan_notification_settings}) AS ns WHERE ns.id = notification_settings.id)") + end + + def down + # This is a no-op method to make the migration reversible. + # If someone is trying to rollback for other reasons, we should not throw an Exception. + # raise ActiveRecord::IrreversibleMigration + end + + def orphan_notification_settings + <<-SQL + SELECT notification_settings.id + FROM notification_settings + LEFT OUTER JOIN namespaces + ON namespaces.id = notification_settings.source_id + WHERE notification_settings.source_type = 'Namespace' + AND namespaces.id IS NULL + SQL + end +end diff --git a/db/migrate/20170419001229_add_index_to_system_note_metadata.rb b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb new file mode 100644 index 00000000000..c68fd920fff --- /dev/null +++ b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb @@ -0,0 +1,17 @@ +class AddIndexToSystemNoteMetadata < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + # MySQL automatically creates an index on a foreign-key constraint; PostgreSQL does not + add_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql? + end + + def down + remove_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql? + end +end |