modify database schema

This commit is contained in:
vincent 2021-05-25 21:55:25 +02:00
parent ad2c967691
commit b3beb2b2cf
2 changed files with 9 additions and 3 deletions

View File

@ -5,6 +5,7 @@ from urllib.parse import urlparse, parse_qsl
from pony.orm import Database, Required, Optional, Set, PrimaryKey, LongStr from pony.orm import Database, Required, Optional, Set, PrimaryKey, LongStr
db = Database() db = Database()
class Service(db.Entity): class Service(db.Entity):
id = PrimaryKey(int, auto=True) id = PrimaryKey(int, auto=True)
name = Required(str, unique=True) name = Required(str, unique=True)
@ -22,6 +23,7 @@ class Planning(db.Entity):
working_plan = Required(LongStr) working_plan = Required(LongStr)
services = Set(Service) services = Set(Service)
appointments = Set('Appointment') appointments = Set('Appointment')
planners = Set('Planner')
class Setting(db.Entity): class Setting(db.Entity):
@ -40,11 +42,11 @@ class Appointment(db.Entity):
service = Required(Service) service = Required(Service)
planning = Required(Planning) planning = Required(Planning)
ticket = Optional('Ticket') ticket = Optional('Ticket')
user = Optional('User') customer = Optional('Customer')
notes = Optional(LongStr) notes = Optional(LongStr)
class User(db.Entity): class Customer(db.Entity):
id = PrimaryKey(int, auto=True) id = PrimaryKey(int, auto=True)
first_name = Required(str) first_name = Required(str)
last_name = Required(str) last_name = Required(str)
@ -61,7 +63,7 @@ class Ticket(db.Entity):
id = PrimaryKey(int, auto=True) id = PrimaryKey(int, auto=True)
ref = Optional(str, unique=True) ref = Optional(str, unique=True)
service_category = Required('Service_category') service_category = Required('Service_category')
user = Required(User) customer = Required(Customer)
appointment = Required(Appointment) appointment = Required(Appointment)
notes = Optional(str) notes = Optional(str)
@ -76,6 +78,10 @@ class Service_category(db.Entity):
description = Optional(str) description = Optional(str)
class Planner(Customer):
plannings = Set(Planning)
password = Required(str)
is_admin = Optional(bool)
def parse_uri(database_uri): def parse_uri(database_uri):
if not isinstance(database_uri, str): if not isinstance(database_uri, str):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 KiB

After

Width:  |  Height:  |  Size: 453 KiB