demarches-normaliennes/db/migrate/20160622081322_add_procedure_path_mapping_table.rb
2018-03-06 17:18:44 +01:00

18 lines
650 B
Ruby

class AddProcedurePathMappingTable < ActiveRecord::Migration
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|
ProcedurePath.create(path: "#{procedure.id}", procedure_id: procedure.id, administrateur_id: procedure.administrateur.id)
end
end
end