Class: CreateDuctworkAvailabilities
- Inherits:
-
Ductwork::Migration
- Object
- Ductwork::Migration
- CreateDuctworkAvailabilities
- Defined in:
- lib/generators/ductwork/install/templates/db/create_ductwork_availabilities.rb
Instance Method Summary collapse
Methods included from Ductwork::MigrationHelper
#belongs_to, #create_ductwork_table, #mysql?, #postgresql?, #uuid_column_type
Instance Method Details
#change ⇒ Object
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 34 35 36 37 38 39 |
# File 'lib/generators/ductwork/install/templates/db/create_ductwork_availabilities.rb', line 4 def change create_ductwork_table :ductwork_availabilities do |table| belongs_to( table, :execution, index: false, null: false, foreign_key: { to_table: :ductwork_executions } ) belongs_to( table, :process, index: true, null: true, foreign_key: { to_table: :ductwork_processes } ) table. :started_at, null: false table. :completed_at table.string :pipeline_klass, null: false table. null: false end add_index :ductwork_availabilities, :execution_id, unique: true add_index :ductwork_availabilities, %i[id process_id] if mysql? add_index :ductwork_availabilities, %i[pipeline_klass completed_at started_at], name: "index_ductwork_availabilities_on_claim_latest" else add_index :ductwork_availabilities, %i[pipeline_klass started_at], name: "index_ductwork_availabilities_on_claim_latest", where: "completed_at IS NULL" end end |