udemy-go-web-2/migrations/20210630183733_create_statuses_table.up.fizz

17 lines
546 B
Plaintext
Raw Normal View History

2024-08-06 19:53:39 +00:00
create_table("statuses") {
t.Column("id", "integer", {primary: true})
t.Column("name", "string", {})
}
sql("alter table statuses alter column created_at set default now();")
sql("alter table statuses alter column updated_at set default now();")
sql("insert into statuses (name) values ('Cleared');")
sql("insert into statuses (name) values ('Refunded');")
sql("insert into statuses (name) values ('Cancelled');")
add_foreign_key("orders", "status_id", {"statuses": ["id"]}, {
"on_delete": "cascade",
"on_update": "cascade",
})