diff --git a/migrations/versions/d2033352cfdf_.py b/migrations/versions/d2033352cfdf_.py new file mode 100644 index 0000000..bf60e8d --- /dev/null +++ b/migrations/versions/d2033352cfdf_.py @@ -0,0 +1,36 @@ +"""empty message + +Revision ID: d2033352cfdf +Revises: b6667aa4e705 +Create Date: 2017-03-04 12:52:51.625451 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'd2033352cfdf' +down_revision = 'b6667aa4e705' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('matrix_room', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('room_id', sa.Text(), nullable=True), + sa.Column('pnut_chan', sa.Text(), nullable=True), + sa.Column('pnut_since', sa.Text(), nullable=True), + sa.Column('pnut_write', sa.Boolean(), nullable=True), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('room_id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('matrix_room') + # ### end Alembic commands ### diff --git a/models.py b/models.py index 3121343..ba0c49c 100644 --- a/models.py +++ b/models.py @@ -16,4 +16,19 @@ class MatrixUser(db.Model): self.pnut_token = pnut_token def __repr__(self): - return '' % self.matrix_id + +class MatrixRoom(db.Model): + id = db.Column(db.Integer, primary_key=True) + room_id = db.Column(db.Text, unique=True) + pnut_chan = db.Column(db.Text) + pnut_since = db.Column(db.Text) + pnut_write = db.Column(db.Boolean, default=True) + + def __init__(self, room_id, pnut_chan, pnut_write=True): + self.room_id = room_id + self.pnut_chan = pnut_chan + self.pnut_write = pnut_write + + def __repr__(self): + return '' % self.room_id