added matrix room model
This commit is contained in:
parent
afaf91c6cc
commit
d59e74919f
2 changed files with 52 additions and 1 deletions
36
migrations/versions/d2033352cfdf_.py
Normal file
36
migrations/versions/d2033352cfdf_.py
Normal file
|
@ -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 ###
|
17
models.py
17
models.py
|
@ -16,4 +16,19 @@ class MatrixUser(db.Model):
|
|||
self.pnut_token = pnut_token
|
||||
|
||||
def __repr__(self):
|
||||
return '<MatrixUser %r' % self.matrix_id
|
||||
return '<MatrixUser %r>' % 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 '<MatrixRoom %r>' % self.room_id
|
||||
|
|
Loading…
Reference in a new issue