Son NK 5 rokov pred
rodič
commit
ffee8757ea

+ 14 - 0
app/models.py

@@ -769,3 +769,17 @@ class Directory(db.Model, ModelMixin):
 
     def __repr__(self):
         return f"<Directory {self.name}>"
+
+
+class Job(db.Model, ModelMixin):
+    """Used to schedule one-time job in the future"""
+
+    name = db.Column(db.String(128), nullable=False)
+    payload = db.Column(db.JSON)
+
+    # whether the job has been taken by the job runner
+    taken = db.Column(db.Boolean, default=False, nullable=False)
+    run_at = db.Column(ArrowType)
+
+    def __repr__(self):
+        return f"<Job {self.id} {self.name} {self.payload}>"

+ 38 - 0
migrations/versions/2020_020313_9c976df9b9c4_.py

@@ -0,0 +1,38 @@
+"""empty message
+
+Revision ID: 9c976df9b9c4
+Revises: 7c39ba4ec38d
+Create Date: 2020-02-03 13:08:29.049797
+
+"""
+import sqlalchemy_utils
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '9c976df9b9c4'
+down_revision = '7c39ba4ec38d'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.create_table('job',
+    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
+    sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
+    sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
+    sa.Column('name', sa.String(length=128), nullable=False),
+    sa.Column('payload', sa.JSON(), nullable=True),
+    sa.Column('taken', sa.Boolean(), nullable=False),
+    sa.Column('run_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
+    sa.PrimaryKeyConstraint('id')
+    )
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_table('job')
+    # ### end Alembic commands ###