demarches-normaliennes/db/migrate/20160622081322_add_procedure_path_mapping_table.rb

19 lines
652 B
Ruby
Raw Normal View History

class AddProcedurePathMappingTable < ActiveRecord::Migration
2018-03-06 13:44:29 +01:00
class ProcedurePath < ApplicationRecord
end
def change
create_table :procedure_paths do |t|
t.string :path, limit: 30, null: true, unique: true, index: true
t.integer :procedure_id, unique: true, null: true
t.integer :administrateur_id, unique: true, null: true
end
add_foreign_key :procedure_paths, :procedures
add_foreign_key :procedure_paths, :administrateurs
Procedure.all.each do |procedure|
2018-10-01 14:03:05 +02:00
ProcedurePath.create(path: (procedure.id).to_s, procedure_id: procedure.id, administrateur_id: procedure.administrateur.id)
end
end
end