udemy-go-web-2/migrations/20210630183342_create_orders_table.up.fizz
2024-08-07 15:51:25 +02:00

21 lines
717 B
Plaintext

create_table("orders") {
t.Column("id", "integer", {primary: true})
t.Column("widget_id", "integer", {"unsigned":true})
t.Column("transaction_id", "integer", {"unsigned":true})
t.Column("status_id", "integer", {"unsigned":true})
t.Column("quantity", "integer", {})
t.Column("amount", "integer", {})
}
sql("alter table orders alter column created_at set default now();")
sql("alter table orders alter column updated_at set default now();")
add_foreign_key("orders", "widget_id", {"widgets": ["id"]}, {
"on_delete": "cascade",
"on_update": "cascade",
})
add_foreign_key("orders", "transaction_id", {"transactions": ["id"]}, {
"on_delete": "cascade",
"on_update": "cascade",
})