summaryrefslogtreecommitdiff
path: root/db/migrate/20210804200114_create_customer_relations_organizations.rb
blob: 9936e97b9bfe85c3b175c399c662d5ca5c85ca9d (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
# frozen_string_literal: true

class CreateCustomerRelationsOrganizations < ActiveRecord::Migration[6.1]
  include Gitlab::Database::MigrationHelpers

  def up
    create_table_with_constraints :customer_relations_organizations do |t|
      t.references :group, index: false, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }
      t.timestamps_with_timezone null: false
      t.integer :state, limit: 1, default: 1, null: false
      t.decimal :default_rate, precision: 18, scale: 2
      t.text :name, null: false
      t.text :description

      t.text_limit :name, 255
      t.text_limit :description, 1024

      t.index 'group_id, LOWER(name)', unique: true, name: :index_customer_relations_organizations_on_unique_name_per_group
    end
  end

  def down
    with_lock_retries do
      drop_table :customer_relations_organizations
    end
  end
end