create event and reservation table
This commit is contained in:
parent
18d7ae9ce7
commit
6e0a21f569
2
migrations/2025-04-07-130716_event_table/down.sql
Normal file
2
migrations/2025-04-07-130716_event_table/down.sql
Normal file
@ -0,0 +1,2 @@
|
||||
DROP TABLE events;
|
||||
|
||||
4
migrations/2025-04-07-130716_event_table/up.sql
Normal file
4
migrations/2025-04-07-130716_event_table/up.sql
Normal file
@ -0,0 +1,4 @@
|
||||
CREATE TABLE events (
|
||||
id SERIAL PRIMARY KEY,
|
||||
time TIMESTAMP UNIQUE NOT NULL
|
||||
);
|
||||
2
migrations/2025-04-07-130908_reservation_table/down.sql
Normal file
2
migrations/2025-04-07-130908_reservation_table/down.sql
Normal file
@ -0,0 +1,2 @@
|
||||
DROP TABLE reservations;
|
||||
DROP TYPE reservation_status;
|
||||
10
migrations/2025-04-07-130908_reservation_table/up.sql
Normal file
10
migrations/2025-04-07-130908_reservation_table/up.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE TYPE reservation_status AS ENUM ('booked', 'paid');
|
||||
|
||||
CREATE TABLE reservations (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER REFERENCES users(id),
|
||||
entered_name VARCHAR(255),
|
||||
booked_time TIMESTAMP NOT NULL,
|
||||
event_id INTEGER REFERENCES events(id),
|
||||
status reservation_status NOT NULL
|
||||
);
|
||||
@ -1,5 +1,18 @@
|
||||
// @generated automatically by Diesel CLI.
|
||||
|
||||
pub mod sql_types {
|
||||
#[derive(diesel::query_builder::QueryId, Clone, diesel::sql_types::SqlType)]
|
||||
#[diesel(postgres_type(name = "reservation_status"))]
|
||||
pub struct ReservationStatus;
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
events (id) {
|
||||
id -> Int4,
|
||||
time -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
literals (id) {
|
||||
id -> Int4,
|
||||
@ -19,6 +32,21 @@ diesel::table! {
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
use diesel::sql_types::*;
|
||||
use super::sql_types::ReservationStatus;
|
||||
|
||||
reservations (id) {
|
||||
id -> Int4,
|
||||
user_id -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
entered_name -> Nullable<Varchar>,
|
||||
booked_time -> Timestamp,
|
||||
event_id -> Nullable<Int4>,
|
||||
status -> ReservationStatus,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
teloxide_dialogues (chat_id) {
|
||||
chat_id -> Int8,
|
||||
@ -41,9 +69,14 @@ diesel::table! {
|
||||
}
|
||||
}
|
||||
|
||||
diesel::joinable!(reservations -> events (event_id));
|
||||
diesel::joinable!(reservations -> users (user_id));
|
||||
|
||||
diesel::allow_tables_to_appear_in_same_query!(
|
||||
events,
|
||||
literals,
|
||||
messages,
|
||||
reservations,
|
||||
teloxide_dialogues,
|
||||
users,
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user