mirror of
https://github.com/simple-login/app.git
synced 2024-09-20 15:05:59 +08:00
add User.lifetime_coupon_id column
This commit is contained in:
parent
c7626dd23e
commit
cef6579946
|
@ -37,6 +37,7 @@ def lifetime_licence():
|
|||
if coupon and coupon.nb_used > 0:
|
||||
coupon.nb_used -= 1
|
||||
current_user.lifetime = True
|
||||
current_user.lifetime_coupon_id = coupon.id
|
||||
if coupon.paid:
|
||||
current_user.paid_lifetime = True
|
||||
db.session.commit()
|
||||
|
|
|
@ -266,6 +266,11 @@ class User(db.Model, ModelMixin, UserMixin, PasswordOracle):
|
|||
paid_lifetime = db.Column(
|
||||
db.Boolean, default=False, nullable=False, server_default="0"
|
||||
)
|
||||
lifetime_coupon_id = db.Column(
|
||||
db.ForeignKey("lifetime_coupon.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
default=None,
|
||||
)
|
||||
|
||||
# user can use all premium features until this date
|
||||
trial_end = db.Column(
|
||||
|
|
31
migrations/versions/2021_100417_0b1c9ea11aef_.py
Normal file
31
migrations/versions/2021_100417_0b1c9ea11aef_.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 0b1c9ea11aef
|
||||
Revises: 4913cb3f5a05
|
||||
Create Date: 2021-10-04 17:14:01.414396
|
||||
|
||||
"""
|
||||
import sqlalchemy_utils
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0b1c9ea11aef'
|
||||
down_revision = '4913cb3f5a05'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('users', sa.Column('lifetime_coupon_id', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(None, 'users', 'lifetime_coupon', ['lifetime_coupon_id'], ['id'], ondelete='SET NULL')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'users', type_='foreignkey')
|
||||
op.drop_column('users', 'lifetime_coupon_id')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in a new issue