From 354e5f9a672172c31b26e0dea6c6975e14ac1ff4 Mon Sep 17 00:00:00 2001 From: Son NK Date: Thu, 30 Jan 2020 10:10:28 +0700 Subject: [PATCH] add User.trial_end column --- app/models.py | 5 ++++ .../versions/2020_013010_7c39ba4ec38d_.py | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 migrations/versions/2020_013010_7c39ba4ec38d_.py diff --git a/app/models.py b/app/models.py index 763ded00..b8a908c3 100644 --- a/app/models.py +++ b/app/models.py @@ -122,6 +122,11 @@ class User(db.Model, ModelMixin, UserMixin): # some users could have lifetime premium lifetime = db.Column(db.Boolean, default=False, nullable=False, server_default="0") + # user can use all premium features until this date + trial_end = db.Column( + ArrowType, default=lambda: arrow.now().shift(days=7), nullable=True + ) + profile_picture = db.relationship(File) @classmethod diff --git a/migrations/versions/2020_013010_7c39ba4ec38d_.py b/migrations/versions/2020_013010_7c39ba4ec38d_.py new file mode 100644 index 00000000..72164058 --- /dev/null +++ b/migrations/versions/2020_013010_7c39ba4ec38d_.py @@ -0,0 +1,29 @@ +"""empty message + +Revision ID: 7c39ba4ec38d +Revises: ba6f13ccbabb +Create Date: 2020-01-30 10:10:01.245257 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '7c39ba4ec38d' +down_revision = 'ba6f13ccbabb' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('trial_end', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'trial_end') + # ### end Alembic commands ###