Browse Source

Add PublicDomain.premium_only column

Son NK 4 years ago
parent
commit
dcbd7baabc
2 changed files with 40 additions and 1 deletions
  1. 11 1
      app/models.py
  2. 29 0
      migrations/versions/2020_101516_54ca2dbf89c0_.py

+ 11 - 1
app/models.py

@@ -1795,10 +1795,20 @@ class Notification(db.Model, ModelMixin):
 
 
 class PublicDomain(db.Model, ModelMixin):
-    """SimpleLogin domains that all users can use"""
+    """SimpleLogin domains"""
 
     domain = db.Column(db.String(128), unique=True, nullable=False)
 
+    # only available for premium accounts
+    premium_only = db.Column(
+        db.Boolean, nullable=False, default=False, server_default="0"
+    )
+
+    def __repr__(self):
+        return (
+            f"<PublicDomain {self.domain} {'Premium' if self.premium_only else 'Free'}"
+        )
+
 
 class Monitoring(db.Model, ModelMixin):
     """

+ 29 - 0
migrations/versions/2020_101516_54ca2dbf89c0_.py

@@ -0,0 +1,29 @@
+"""empty message
+
+Revision ID: 54ca2dbf89c0
+Revises: b17afc77ba83
+Create Date: 2020-10-15 16:07:57.039554
+
+"""
+import sqlalchemy_utils
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '54ca2dbf89c0'
+down_revision = 'b17afc77ba83'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('public_domain', sa.Column('premium_only', sa.Boolean(), server_default='0', nullable=False))
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('public_domain', 'premium_only')
+    # ### end Alembic commands ###