Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20161223034646_create_timelogs_ce.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 66d9cd823fb646f1d338e76b290c3de34101453a (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
class CreateTimelogsCe < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  def up
    unless table_exists?(:timelogs)
      create_table :timelogs do |t|
        t.integer :time_spent, null: false
        t.references :trackable, polymorphic: true
        t.references :user

        t.timestamps null: false
      end

      add_index :timelogs, [:trackable_type, :trackable_id]
      add_index :timelogs, :user_id
    end
  end

  def down
    drop_table :timelogs if table_exists?(:timelogs)
  end
end