class CreateEcomModelProjects < ActiveRecord::Migration[6.0] def change create_table :ecom_model_projects do |t| t.string :name, null: false t.string :description t.string :location, null: false t.string :objective t.string :project_scope t.references :employer, index: { name: 'employer_on_projects_indx' } t.references :contractor, index: { name: 'employer_on_contractor_indx' } t.references :consultant, index: { name: 'employer_on_consultant_indx' } t.references :project_manager, index: { name: 'employer_on_pm_indx' } t.references :task_template, index: { name: 'employer_on_tt_indx' } t.string :contract_number, null: false t.date :date_contract_signed, null: false t.date :commencement_date, null: false t.date :completion_date, null: false t.float :contract_amount, null: false t.float :advance_payment, null: false t.float :retention, null: false t.string :remark t.references :currency, index: { name: 'employer_on_currency_indx' } t.timestamps end add_foreign_key :ecom_model_projects, :ecom_model_stakeholders, column: :employer_id add_foreign_key :ecom_model_projects, :ecom_model_stakeholders, column: :contractor_id add_foreign_key :ecom_model_projects, :ecom_model_stakeholders, column: :consultant_id add_foreign_key :ecom_model_projects, :ecom_model_stakeholders, column: :project_manager_id add_foreign_key :ecom_model_projects, :ecom_model_task_templates, column: :task_template_id add_foreign_key :ecom_model_projects, :ecom_model_currencies, column: :currency_id end end