23 lines
454 B
Crystal
23 lines
454 B
Crystal
|
class CreateRoles::V00000000000002 < Avram::Migrator::Migration::V1
|
||
|
def migrate
|
||
|
create table_for(Role) do
|
||
|
primary_key id : Int64
|
||
|
|
||
|
add name : String, unique: true
|
||
|
add description : String?
|
||
|
end
|
||
|
|
||
|
alter table_for(User) do
|
||
|
add_belongs_to primary_role : Role, on_delete: :restrict
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def rollback
|
||
|
alter table_for(User) do
|
||
|
remove_belongs_to :primary_role
|
||
|
end
|
||
|
|
||
|
drop table_for(Role)
|
||
|
end
|
||
|
end
|