-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ntvviktor/viktor/feature/CRUD-favourite-list
complete CRUD favourite functionality endpoint
- Loading branch information
Showing
28 changed files
with
666 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""second update | ||
Revision ID: 1078920783b3 | ||
Revises: 0126d9492ccb | ||
Create Date: 2024-04-29 21:13:51.079162 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '1078920783b3' | ||
down_revision = '0126d9492ccb' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('favourite_list', | ||
sa.Column('user_id', sa.String(length=250), nullable=False), | ||
sa.Column('book_isbn', sa.String(length=30), nullable=False), | ||
sa.ForeignKeyConstraint(['book_isbn'], ['books.isbn'], ), | ||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), | ||
sa.PrimaryKeyConstraint('user_id', 'book_isbn') | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('favourite_list') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
from sqlalchemy import PrimaryKeyConstraint | ||
from .. import db | ||
import shortuuid | ||
|
||
|
||
class FavouriteList(db.Model): | ||
__tablename__ = 'favourite_list' | ||
|
||
id = db.Column(db.Integer, primary_key=True) | ||
user_id = db.Column(db.Integer, db.ForeignKey('users.id')) | ||
book_isbn = db.Column(db.Integer, db.ForeignKey('books.isbn')) | ||
user_id = db.Column(db.String(250), db.ForeignKey('users.id')) | ||
book_isbn = db.Column(db.String(30), db.ForeignKey('books.isbn')) | ||
|
||
__table_args__ = ( | ||
PrimaryKeyConstraint( | ||
user_id, | ||
book_isbn), | ||
{}) | ||
|
||
def __init__(self, user_id, book_isbn): | ||
self.id = shortuuid.uuid() | ||
self.user_id = user_id | ||
self.book_isbn = book_isbn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.