summaryrefslogtreecommitdiff
path: root/db/migrate/20210317104301_create_in_product_marketing_emails.rb
blob: b8c6b952c970fb3ef9f861b6e4f6ec7b1aba91b2 (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
29
30
31
32
33
# frozen_string_literal: true

class CreateInProductMarketingEmails < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  UNIQUE_INDEX_NAME = 'index_in_product_marketing_emails_on_user_track_series'

  disable_ddl_transaction!

  def up
    with_lock_retries do
      create_table :in_product_marketing_emails do |t|
        t.bigint :user_id, null: false
        t.datetime_with_timezone :cta_clicked_at
        t.integer :track, null: false, limit: 2
        t.integer :series, null: false, limit: 2

        t.timestamps_with_timezone
      end
    end

    add_index :in_product_marketing_emails, :user_id
    add_index :in_product_marketing_emails, [:user_id, :track, :series], unique: true, name: UNIQUE_INDEX_NAME
  end

  def down
    with_lock_retries do
      drop_table :in_product_marketing_emails
    end
  end
end