Skip to content

Commit

Permalink
latest db rev
Browse files Browse the repository at this point in the history
  • Loading branch information
boris committed Apr 27, 2024
1 parent 1862574 commit 45c6fac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from flask_login import UserMixin
from . import db

# many-to-many books/tags
tags = db.Table('books_tags',
db.Column('id_tag', db.Integer, db.ForeignKey('tag.id'), primary_key=True),
db.Column('id_book', db.Integer, db.ForeignKey('book.id'), primary_key=True)
)
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
email = db.Column(db.String(100), unique=True, nullable=False)
Expand All @@ -27,6 +32,8 @@ class Book(db.Model):
editorial = db.relationship('Editorial', backref='books')
genre = db.relationship('Genre', backref='books')

book_tags = db.relationship('Tag', secondary=tags, backref=db.backref('books', lazy='dynamic'))


class Author(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
Expand All @@ -48,12 +55,6 @@ class Genre(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(255), primary_key=True)

# many-to-many books/tags
tags = db.Table('books_tags',
db.Column('id_tag', db.Integer, db.ForeignKey('tag.id'), primary_key=True),
db.Column('id_book', db.Integer, db.ForeignKey('book.id'), primary_key=True)
)


class Quotes(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
Expand Down
24 changes: 24 additions & 0 deletions migrations/versions/0fdda1165133_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""empty message
Revision ID: 0fdda1165133
Revises: a7e98095982b
Create Date: 2024-04-26 23:25:36.332371
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '0fdda1165133'
down_revision = 'a7e98095982b'
branch_labels = None
depends_on = None


def upgrade():
pass


def downgrade():
pass
Binary file not shown.

0 comments on commit 45c6fac

Please sign in to comment.