add customers

This commit is contained in:
2024-08-07 16:22:52 +02:00
parent f3f0bf531c
commit 88be25d77f
7 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1 @@
drop_table("customers")

View File

@ -0,0 +1,9 @@
create_table("customers") {
t.Column("id", "integer", {primary: true})
t.Column("first_name", "string", {"size": 255})
t.Column("last_name", "string", {"size": 255})
t.Column("email", "string", {})
}
sql("alter table customers alter column created_at set default now();")
sql("alter table customers alter column updated_at set default now();")

View File

@ -0,0 +1,3 @@
drop_column("transactions", "expiry_month")
drop_column("transactions", "expiry_year")

View File

@ -0,0 +1,3 @@
add_column("transactions", "expiry_month", "integer", {"default":0})
add_column("transactions", "expiry_year", "integer", {"default":0})

View File

@ -0,0 +1 @@
drop_column("orders", "customer_id")

View File

@ -0,0 +1,6 @@
add_column("orders", "customer_id", "integer", {"unsigned":true})
add_foreign_key("orders", "customer_id", {"customers": ["id"]}, {
"on_delete": "cascade",
"on_update": "cascade",
})