mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Add Organisation model and migration
Now that we have renamed the 'old' organisation model to email_branding, we can create a new organisation model.
This commit is contained in:
@@ -303,6 +303,15 @@ class Service(db.Model, Versioned):
|
|||||||
return permission in [p.permission for p in self.permissions]
|
return permission in [p.permission for p in self.permissions]
|
||||||
|
|
||||||
|
|
||||||
|
class Organisation(db.Model):
|
||||||
|
__tablename__ = "organisation"
|
||||||
|
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, unique=False)
|
||||||
|
name = db.Column(db.String(255), nullable=False, unique=True, index=True)
|
||||||
|
active = db.Column(db.Boolean, nullable=False, default=True)
|
||||||
|
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
|
||||||
|
updated_at = db.Column(db.DateTime, nullable=True, onupdate=datetime.datetime.utcnow)
|
||||||
|
|
||||||
|
|
||||||
class AnnualBilling(db.Model):
|
class AnnualBilling(db.Model):
|
||||||
__tablename__ = "annual_billing"
|
__tablename__ = "annual_billing"
|
||||||
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, unique=False)
|
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, unique=False)
|
||||||
|
|||||||
34
migrations/versions/0163_add_new_org_model.py
Normal file
34
migrations/versions/0163_add_new_org_model.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
"""
|
||||||
|
|
||||||
|
Revision ID: 0163_add_new_org_model
|
||||||
|
Revises: 0162_remove_org
|
||||||
|
Create Date: 2018-02-07 14:03:00.804849
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
revision = '0163_add_new_org_model'
|
||||||
|
down_revision = '0162_remove_org'
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('organisation',
|
||||||
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('active', sa.Boolean(), nullable=False),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(op.f('ix_organisation_name'), 'organisation', ['name'], unique=True)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_index(op.f('ix_organisation_name'), table_name='organisation')
|
||||||
|
op.drop_table('organisation')
|
||||||
|
# ### end Alembic commands ###
|
||||||
Reference in New Issue
Block a user