Running database migrations
This commit is contained in:
parent
ab4fda918a
commit
00a2d639f5
BIN
migrations/migrations/.DS_Store
vendored
Normal file
BIN
migrations/migrations/.DS_Store
vendored
Normal file
Binary file not shown.
@ -0,0 +1,12 @@
|
||||
create_table("widgets") {
|
||||
t.Column("id", "integer", {primary: true})
|
||||
t.Column("name", "string", {"default": ""})
|
||||
t.Column("description", "text", {"default": ""})
|
||||
t.Column("inventory_level", "integer", {})
|
||||
t.Column("price", "integer", {})
|
||||
}
|
||||
|
||||
sql("alter table widgets alter column created_at set default now();")
|
||||
sql("alter table widgets alter column updated_at set default now();")
|
||||
|
||||
sql("insert into widgets (name, description, inventory_level, price, created_at, updated_at) values ('Widget', 'A very nice widget.', 10, 1000, now(), now());")
|
@ -0,0 +1,13 @@
|
||||
create_table("transaction_statuses") {
|
||||
t.Column("id", "integer", {primary: true})
|
||||
t.Column("name", "string", {})
|
||||
}
|
||||
|
||||
sql("alter table transaction_statuses alter column created_at set default now();")
|
||||
sql("alter table transaction_statuses alter column updated_at set default now();")
|
||||
|
||||
sql("insert into transaction_statuses (name) values ('Pending');")
|
||||
sql("insert into transaction_statuses (name) values ('Cleared');")
|
||||
sql("insert into transaction_statuses (name) values ('Declined');")
|
||||
sql("insert into transaction_statuses (name) values ('Refunded');")
|
||||
sql("insert into transaction_statuses (name) values ('Partially refunded');")
|
@ -0,0 +1 @@
|
||||
drop_table("transactions")
|
@ -0,0 +1,16 @@
|
||||
create_table("transactions") {
|
||||
t.Column("id", "integer", {primary: true})
|
||||
t.Column("amount", "integer", {})
|
||||
t.Column("currency", "string", {})
|
||||
t.Column("last_four", "string", {})
|
||||
t.Column("bank_return_code", "string", {})
|
||||
t.Column("transaction_status_id", "integer", {"unsigned": true})
|
||||
}
|
||||
|
||||
sql("alter table transactions alter column created_at set default now();")
|
||||
sql("alter table transactions alter column updated_at set default now();")
|
||||
|
||||
add_foreign_key("transactions", "transaction_status_id", {"transaction_statuses": ["id"]}, {
|
||||
"on_delete": "cascade",
|
||||
"on_update": "cascade",
|
||||
})
|
@ -0,0 +1 @@
|
||||
drop_table("orders")
|
@ -0,0 +1,21 @@
|
||||
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",
|
||||
})
|
@ -0,0 +1 @@
|
||||
drop_table("statuses")
|
@ -0,0 +1,16 @@
|
||||
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",
|
||||
})
|
@ -0,0 +1 @@
|
||||
drop_table("users")
|
@ -0,0 +1,12 @@
|
||||
create_table("users") {
|
||||
t.Column("id", "integer", {primary: true})
|
||||
t.Column("first_name", "string", {"size": 255})
|
||||
t.Column("last_name", "string", {"size": 255})
|
||||
t.Column("email", "string", {})
|
||||
t.Column("password", "string", {"size": 60})
|
||||
}
|
||||
|
||||
sql("alter table users alter column created_at set default now();")
|
||||
sql("alter table users alter column updated_at set default now();")
|
||||
|
||||
sql("insert into users (first_name, last_name, email, password) values ('Admin','User','admin@example.com', '$2a$12$VR1wDmweaF3ZTVgEHiJrNOSi8VcS4j0eamr96A/7iOe8vlum3O3/q');")
|
Loading…
Reference in New Issue
Block a user