summaryrefslogtreecommitdiff
path: root/db/migrate/20191118053631_add_group_deletion_schedules.rb
blob: 6f3ed27e1562da7e2f31ef9643c4aaa914463627 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

class AddGroupDeletionSchedules < ActiveRecord::Migration[5.2]
  DOWNTIME = false

  def up
    create_table :group_deletion_schedules, id: false do |t|
      t.references :group,
        foreign_key: { on_delete: :cascade, to_table: :namespaces },
        default: nil,
        index: false,
        primary_key: true

      t.references :user,
        index: true,
        foreign_key: { on_delete: :nullify },
        null: false

      t.date :marked_for_deletion_on,
        index: true,
        null: false
    end
  end

  def down
    drop_table :group_deletion_schedules
  end
end