feat: add models
This commit is contained in:
5
app/models/adoption_status.py
Normal file
5
app/models/adoption_status.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from app.extensions import db
|
||||||
|
|
||||||
|
class AdoptionStatus(db.Model):
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
status = db.Column(db.String(255), nullable=False)
|
||||||
13
app/models/adoptions.py
Normal file
13
app/models/adoptions.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from app.extensions import db
|
||||||
|
import datetime
|
||||||
|
from sqlalchemy.orm import relationship, mapped_column
|
||||||
|
|
||||||
|
class Adoptions(db.Model) :
|
||||||
|
id = mapped_column(db.Integer, primary_key=True)
|
||||||
|
publisher_id = mapped_column(db.Integer, db.ForeignKey('user.id'), nullable=False)
|
||||||
|
pet_id = mapped_column(db.Integer, db.ForeignKey('pet.id'), nullable=False)
|
||||||
|
publish_date = mapped_column(db.DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||||
|
status_id = mapped_column(db.Integer, db.ForeignKey('adoption_status.id'), nullable=False)
|
||||||
|
publisher = relationship("User")
|
||||||
|
pet = relationship("Pet")
|
||||||
|
status = relationship("AdoptionStatus")
|
||||||
15
app/models/pet.py
Normal file
15
app/models/pet.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import datetime
|
||||||
|
from sqlalchemy.orm import relationship, mapped_column
|
||||||
|
from app.extensions import db
|
||||||
|
|
||||||
|
class Pet(db.Model):
|
||||||
|
id = mapped_column(db.Integer, primary_key=True)
|
||||||
|
name = mapped_column(db.String(255), nullable=False)
|
||||||
|
kind_id = mapped_column(db.Integer, db.ForeignKey('pet_kind.id'), nullable=False)
|
||||||
|
age = mapped_column(db.Integer, default=0, nullable=False)
|
||||||
|
weight = mapped_column(db.Float, default=0, nullable=False)
|
||||||
|
location = mapped_column(db.String(255), nullable=False)
|
||||||
|
sex = mapped_column(db.String(1), nullable=False)
|
||||||
|
height = mapped_column(db.Float, default=0, nullable=False)
|
||||||
|
registration_date = mapped_column(db.DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||||
|
kind = relationship("PetKind")
|
||||||
5
app/models/pet_kind.py
Normal file
5
app/models/pet_kind.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from app.extensions import db
|
||||||
|
|
||||||
|
class PetKind(db.Model):
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
name = db.Column(db.String(255), nullable=False)
|
||||||
15
app/models/user.py
Normal file
15
app/models/user.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import datetime
|
||||||
|
from sqlalchemy.orm import mapped_column
|
||||||
|
from app.extensions import db
|
||||||
|
|
||||||
|
class User(db.Model):
|
||||||
|
id = mapped_column(db.Integer, primary_key=True)
|
||||||
|
username = mapped_column(db.String(255), nullable=False)
|
||||||
|
email = mapped_column(db.String(255), nullable=False)
|
||||||
|
password = mapped_column(db.Text, nullable=False)
|
||||||
|
name = mapped_column(db.String(255), nullable=False)
|
||||||
|
lastname = mapped_column(db.String(255), nullable=False)
|
||||||
|
birth_date = mapped_column(db.Date, nullable=False)
|
||||||
|
address = mapped_column(db.String(255), nullable=False)
|
||||||
|
phone_number = mapped_column(db.String(255), nullable=False)
|
||||||
|
registration_date = mapped_column(db.DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||||
Reference in New Issue
Block a user