add customers
This commit is contained in:
parent
f3f0bf531c
commit
88be25d77f
@ -40,6 +40,7 @@ type Order struct {
|
||||
ID int `json:"id"`
|
||||
WidgetID int `json:"widget_id"`
|
||||
TransactionID int `json:"transaction_id"`
|
||||
CustomerID int `json:"customer_id"`
|
||||
StatusID int `json:"status_id"`
|
||||
Quantity int `json:"quantity"`
|
||||
Amount int `json:"amount"`
|
||||
@ -86,6 +87,16 @@ type User struct {
|
||||
UpdatedAt time.Time `json:"-"`
|
||||
}
|
||||
|
||||
// Customer is the type for customers
|
||||
type Customer struct {
|
||||
ID int `json:"id"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Email string `json:"email"`
|
||||
CreatedAt time.Time `json:"-"`
|
||||
UpdatedAt time.Time `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DBModel) GetWidget(id int) (Widget, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
|
@ -0,0 +1 @@
|
||||
drop_table("customers")
|
9
migrations/20240807135144_create_customer_table.up.fizz
Normal file
9
migrations/20240807135144_create_customer_table.up.fizz
Normal 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();")
|
@ -0,0 +1,3 @@
|
||||
drop_column("transactions", "expiry_month")
|
||||
drop_column("transactions", "expiry_year")
|
||||
|
@ -0,0 +1,3 @@
|
||||
add_column("transactions", "expiry_month", "integer", {"default":0})
|
||||
add_column("transactions", "expiry_year", "integer", {"default":0})
|
||||
|
@ -0,0 +1 @@
|
||||
drop_column("orders", "customer_id")
|
@ -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",
|
||||
})
|
Loading…
Reference in New Issue
Block a user