Skip to content

Commit

Permalink
adding migration scrips
Browse files Browse the repository at this point in the history
  • Loading branch information
rozdolsky33 committed Dec 3, 2023
1 parent 5009f85 commit d19772f
Show file tree
Hide file tree
Showing 22 changed files with 471 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ main
web
.idea
booking-app
database.yml
migrations
database.yml
1 change: 1 addition & 0 deletions migrations/20231203000801_create_user_table.down.fizz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sql("drop table users")
8 changes: 8 additions & 0 deletions migrations/20231203000801_create_user_table.up.fizz
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
create_table("users") {
t.Column("id", "integer", {primary: true})
t.Column("first_name", "string", {"default": ""})
t.Column("last_name", "string", {"default": ""})
t.Column("email", "string", {"default": ""})
t.Column("password", "string", {"size": 60})
t.Column("access_level", "integer", {"default": 1})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop_table("reservations");
10 changes: 10 additions & 0 deletions migrations/20231203004218_create_reservation_table.up.fizz
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
create_table("reservations") {
t.Column("id", "integer", {primary: true})
t.Column("first_name", "string", {"default": ""})
t.Column("last_name", "string", {"default": ""})
t.Column("email", "string", {})
t.Column("phone", "string", {"default": ""})
t.Column("start_date", "date", {})
t.Column("end_date", "date", {})
t.Column("room_id", "integer", {})
}
1 change: 1 addition & 0 deletions migrations/20231203025147_create_rooms_table.down.fizz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop_table("rooms");
4 changes: 4 additions & 0 deletions migrations/20231203025147_create_rooms_table.up.fizz
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
create_table("rooms") {
t.Column("id", "integer", {primary: true})
t.Column("room_name", "string", {"default": ""})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop_table("restrictions");
4 changes: 4 additions & 0 deletions migrations/20231203025611_create_restrictions_table.up.fizz
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
create_table("restrictions") {
t.Column("id", "integer", {primary: true})
t.Column("room_name", "string", {"default": ""})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop_table("room_restrictions");
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
create_table("room_restrictions") {
t.Column("id", "integer", {primary: true})
t.Column("start_date", "date", {})
t.Column("end_date", "date", {})
t.Column("room_id", "integer", {})
t.Column("reservation_id", "integer", {})
t.Column("restriction_id", "integer", {})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop_foreign_key("reservations", "reservations_rooms_id_fk", {})
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_foreign_key("reservations", "room_id", {"rooms": ["id"]}, {
"on_delete": "cascade",
"on_update": "cascade",
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
drop_foreign_key("room_restrictions", "room_restrictions_restrictions_id_fk", {})
drop_foreign_key("room_restrictions", "room_restrictions_rooms_id_fk", {})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_foreign_key("room_restrictions", "room_id", {"rooms": ["id"]}, {
"on_delete": "cascade",
"on_update": "cascade",
})

add_foreign_key("room_restrictions", "restriction_id", {"restrictions": ["id"]}, {
"on_delete": "cascade",
"on_update": "cascade",
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop_index("users", "users_email_idx")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_index("users", "email", {"unique": true})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
drop_index("room_restrictions", "room_restrictions_reservation_id_idx")
drop_index("room_restrictions", "room_restrictions_room_id_idx")
drop_index("room_restrictions", "room_restrictions_start_date_end_date_idx")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_index("room_restrictions", ["start_date", "end_date"], {})
add_index("room_restrictions", ["room_id"], {})
add_index("room_restrictions", ["reservation_id"], {})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
drop_foreign_key("room_restrictions", "room_restrictions_restrictions_id_fk", {})

drop_index("reservation", "reservations_email_idx")
drop_index("reservation", "reservations_last_name_idx")

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_foreign_key("room_restrictions", "reservation_id", {"reservations": ["id"]}, {
"on_delete": "cascade",
"on_update": "cascade",
})

add_index("reservations", "email", {})
add_index("reservations", "last_name", {})
Loading

0 comments on commit d19772f

Please sign in to comment.