solidarity-service/storage/postgresql/schema.hcl

175 lines
3.0 KiB
HCL

table "passengers" {
schema = schema.solidarity_service
column "passenger_id" {
null = false
type = uuid
}
column "alias" {
null = false
type = varchar(15)
}
column "last_name" {
null = true
type = text
}
column "first_name" {
null = true
type = text
}
column "grade" {
null = true
type = int
}
column "picture" {
null = true
type = varchar(200)
}
column "verified_identity"{
null = true
type = bool
}
column "operator" {
null = false
type = varchar(35)
}
column "preferences" {
null = true
type = jsonb
}
primary_key {
columns = [column.passenger_id]
}
}
table "drivers" {
schema = schema.solidarity_service
column "driver_id" {
null = false
type = uuid
}
column "driver_departure_route" {
null = false
type = jsonb
}
column "driver_radius" {
null = false
type = integer
}
column "last_name" {
null = true
type = text
}
column "first_name" {
null = true
type = text
}
column "grade" {
null = true
type = int
}
column "alias" {
null = false
type = varchar(15)
}
column "picture" {
null = true
type = text
}
column "verified_identity"{
null = true
type = bool
}
column "preferences" {
null = true
type = jsonb
}
column "availabilities_type" {
null = false
type = enum.availabilities_type
}
column "availabilities" {
null = false
type = jsonb
}
column "car" {
null = true
type = jsonb
}
column "operator" {
null = false
type = varchar(35)
}
primary_key {
columns = [column.driver_id]
}
}
table "bookings" {
schema = schema.solidarity_service
column "booking_id" {
null = false
type = uuid
}
column "driver_id" {
null = false
type = uuid
}
column "operator" {
null = false
type = varchar(35)
}
column "passenger_id" {
null = false
type = uuid
}
column "booking_status" {
null = false
type = enum.bookingstatus
}
column "departure_address" {
null = false
type = jsonb
}
column "destination_address" {
null = false
type = jsonb
}
column "pickup_date" {
null = false
type = int
}
column "duration"{
null = false
type = int
}
column "distance"{
null = false
type = float
}
primary_key {
columns = [column.booking_id]
}
foreign_key "bookings_driver_id_fkey" {
columns = [column.driver_id]
ref_columns = [table.drivers.column.driver_id]
}
foreign_key "group_members_passenger_id_fkey" {
columns = [column.passenger_id]
ref_columns = [table.passengers.column.passenger_id]
}
}
enum "booking_status" {
schema = schema.solidarity_service
values = ["INITIATED", "WAITING_PASSENGER_CONFIRMATION", "WAITING_DRIVER_CONFIRMATION", "CONFIRMED", "CANCELLED", "COMPLETED_PENDING_VALIDATION", "VALIDATED"]
}
enum "availabilities_type" {
schema = schema.solidarity_service
values = ["PUNCTUAL","REGULAR"]
}
schema "solidarity_service" {
}