p = 'backend/app/models/flashcard.py'
s = open(p).read()

s = s.replace('''    #: "known" or "again". Two outcomes, because a self-graded scale of four
    #: asks a learner to rate their own recall on a scale they have not
    #: calibrated, and the extra resolution is noise.
    outcome = Column(String(10), nullable=False)
    created_at = Column(DateTime, default=datetime.utcnow, index=True)''',
'''    #: "known" or "again". Kept because every row written before there was a
    #: scheduler has one and nothing else; new rows set it from the rating so
    #: the old queries still work.
    outcome = Column(String(10), nullable=False)
    #: 1 Again, 2 Hard, 3 Good, 4 Easy. Null on rows written before the
    #: scheduler existed — a two-way verdict cannot be widened after the fact.
    rating = Column(Integer, nullable=True)
    #: How long it had actually been, and how long it was meant to be. These
    #: two are what FSRS trains on; logging them from the start means the
    #: scheduler can be replaced later without the history being useless.
    elapsed_days = Column(Float, nullable=True)
    scheduled_days = Column(Float, nullable=True)
    created_at = Column(DateTime, default=datetime.utcnow, index=True)''')

s = s.replace('''    category_id = Column(Integer, ForeignKey("question_categories.id", ondelete="SET NULL"), nullable=True, index=True)''',
'''    category_id = Column(Integer, ForeignKey("question_categories.id", ondelete="SET NULL"), nullable=True, index=True)
    #: The article this deck was made from, where there is one. A derived deck
    #: takes its category from the article and can be regenerated when the
    #: article moves on; a deck with no source is one somebody wrote by hand,
    #: which is how a deck spans three articles. Null is not an orphan.
    source_article_id = Column(Integer, ForeignKey("articles.id", ondelete="SET NULL"),
                               nullable=True, index=True)
    #: What the article said when the cards were made. Compared with the
    #: article's updated_at to show "the article has changed since" — a badge,
    #: never a silent regeneration, because regenerating throws away the
    #: scheduling a learner has built up.
    source_synced_at = Column(DateTime, nullable=True)''')
open(p, 'w').write(s)
print('written')
