default next_delete to null

This commit is contained in:
codl 2017-08-31 21:22:22 +02:00
parent c897edf294
commit 8ab74eb306
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
2 changed files with 28 additions and 5 deletions

View File

@ -0,0 +1,26 @@
"""default next_delete to null
Revision ID: 41ef02e66382
Revises: f95af1a8d89f
Create Date: 2017-08-31 21:19:44.304952
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '41ef02e66382'
down_revision = 'f95af1a8d89f'
branch_labels = None
depends_on = None
def upgrade():
op.alter_column('accounts', 'next_delete', server_default=None)
op.execute("UPDATE accounts SET next_delete = NULL where next_delete = 'epoch';")
def downgrade():
op.alter_column('accounts', 'next_delete', server_default='epoch')
op.execute("UPDATE accounts SET next_delete = 'epoch' where next_delete IS NULL;")

View File

@ -97,10 +97,8 @@ class Account(TimestampMixin, RemoteIDMixin):
server_default='epoch', index=True)
last_refresh = db.Column(db.DateTime(timezone=True),
server_default='epoch', index=True)
last_delete = db.Column(db.DateTime(timezone=True),
index=True)
next_delete = db.Column(db.DateTime(timezone=True),
server_default='epoch', index=True)
last_delete = db.Column(db.DateTime(timezone=True), index=True)
next_delete = db.Column(db.DateTime(timezone=True), index=True)
def touch_fetch(self):
self.last_fetch = db.func.now()
@ -142,7 +140,6 @@ class Account(TimestampMixin, RemoteIDMixin):
datetime.now(timezone.utc) + self.policy_delete_every)
return enable
# backref: tokens
# backref: twitter_archives
# backref: posts