diff options
Diffstat (limited to 'db/migrate/20200607223047_create_cluster_agents.rb')
-rw-r--r-- | db/migrate/20200607223047_create_cluster_agents.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/db/migrate/20200607223047_create_cluster_agents.rb b/db/migrate/20200607223047_create_cluster_agents.rb new file mode 100644 index 00000000000..50dd28562e4 --- /dev/null +++ b/db/migrate/20200607223047_create_cluster_agents.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class CreateClusterAgents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:cluster_agents) + with_lock_retries do + create_table :cluster_agents do |t| + t.timestamps_with_timezone null: false + t.belongs_to(:project, null: false, index: true, foreign_key: { on_delete: :cascade }) + t.text :name, null: false + + t.index [:project_id, :name], unique: true + end + end + end + + add_text_limit :cluster_agents, :name, 255 + end + + def down + with_lock_retries do + drop_table :cluster_agents + end + end +end |