diff options
Diffstat (limited to 'db/migrate')
3 files changed, 62 insertions, 0 deletions
diff --git a/db/migrate/20200311154110_create_vulnerability_exports.rb b/db/migrate/20200311154110_create_vulnerability_exports.rb new file mode 100644 index 00000000000..f3162f8808c --- /dev/null +++ b/db/migrate/20200311154110_create_vulnerability_exports.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class CreateVulnerabilityExports < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :vulnerability_exports do |t| + t.timestamps_with_timezone null: false + t.datetime_with_timezone :started_at + t.datetime_with_timezone :finished_at + t.string :status, limit: 255, null: false + t.string :file, limit: 255 + t.bigint :project_id, null: false + t.bigint :author_id, null: false + t.integer :file_store + t.integer :format, limit: 2, null: false, default: 0 + + t.index %i[project_id id], unique: true + t.index %i[author_id] + end + end +end diff --git a/db/migrate/20200316173312_add_vulnerability_export_project_foreign_key.rb b/db/migrate/20200316173312_add_vulnerability_export_project_foreign_key.rb new file mode 100644 index 00000000000..23837f559d2 --- /dev/null +++ b/db/migrate/20200316173312_add_vulnerability_export_project_foreign_key.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddVulnerabilityExportProjectForeignKey < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :vulnerability_exports, :projects, column: :project_id, on_delete: :cascade, index: false # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :vulnerability_exports, column: :project_id + end + end +end diff --git a/db/migrate/20200317142110_add_vulnerability_export_user_foreign_key.rb b/db/migrate/20200317142110_add_vulnerability_export_user_foreign_key.rb new file mode 100644 index 00000000000..032577f2f2a --- /dev/null +++ b/db/migrate/20200317142110_add_vulnerability_export_user_foreign_key.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddVulnerabilityExportUserForeignKey < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :vulnerability_exports, :users, column: :author_id, on_delete: :cascade, index: false # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :vulnerability_exports, column: :author_id + end + end +end |