bug: model fix

This commit is contained in:
Lunaresk 2024-06-16 17:25:43 +02:00
parent 560016cc18
commit 14b7e1f84c
3 changed files with 3 additions and 43 deletions

View File

@ -1,40 +0,0 @@
"""new table for bought entries with unknown items
Revision ID: 24b8e319c0d0
Revises: 015f4256bb4c
Create Date: 2024-06-02 13:14:38.681605
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '24b8e319c0d0'
down_revision = '015f4256bb4c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('payment', schema=None) as batch_op:
batch_op.alter_column('token',
existing_type=sa.VARCHAR(length=15),
nullable=True)
batch_op.drop_constraint('payment_token_fkey', type_='foreignkey')
batch_op.create_foreign_key(None, 'login_token', ['token'], ['token'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('payment', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='foreignkey')
batch_op.create_foreign_key('payment_token_fkey', 'login_token', ['token'], ['token'], onupdate='CASCADE', ondelete='CASCADE')
batch_op.alter_column('token',
existing_type=sa.VARCHAR(length=15),
nullable=False)
# ### end Alembic commands ###

View File

@ -1,7 +1,7 @@
"""new table for bought entries with unknown items 2
Revision ID: 2a64d3b9235a
Revises: 24b8e319c0d0
Revises: 015f4256bb4c
Create Date: 2024-06-02 13:19:59.901053
"""
@ -11,7 +11,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2a64d3b9235a'
down_revision = '24b8e319c0d0'
down_revision = '015f4256bb4c'
branch_labels = None
depends_on = None

View File

@ -4,7 +4,7 @@ from src import db
class Payment(db.Model):
id = db.Column(db.BigInteger, primary_key=True, autoincrement=True)
token = db.Column(db.ForeignKey('login_token.token'),
server_onupdate=db.FetchedValue())
server_onupdate=db.FetchedValue(), nullable=False)
date = db.Column(db.Date, nullable=False, server_default=db.func.now())
amount = db.Column(db.BigInteger, nullable=False, server_default=str(0))