mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
Merge pull request #1233 from alphagov/imdad-migration-add-email-from
[1/5] Create new ServiceEmailReplyTo table
This commit is contained in:
@@ -1329,3 +1329,17 @@ class MonthlyBilling(db.Model):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return str(self.serialized())
|
return str(self.serialized())
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceEmailReplyTo(db.Model):
|
||||||
|
__tablename__ = "service_email_reply_to"
|
||||||
|
|
||||||
|
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||||
|
|
||||||
|
service_id = db.Column(UUID(as_uuid=True), db.ForeignKey('services.id'), unique=False, index=True, nullable=False)
|
||||||
|
service = db.relationship(Service, backref=db.backref("reply_to_email_addresses", uselist=False))
|
||||||
|
|
||||||
|
email_address = db.Column(db.Text, nullable=False, index=False, unique=False)
|
||||||
|
is_default = 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)
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
"""${message}
|
"""
|
||||||
|
|
||||||
Revision ID: ${up_revision}
|
Revision ID: ${up_revision}
|
||||||
Revises: ${down_revision}
|
Revises: ${down_revision}
|
||||||
Create Date: ${create_date}
|
Create Date: ${create_date}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision = ${repr(up_revision)}
|
|
||||||
down_revision = ${repr(down_revision)}
|
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
${imports if imports else ""}
|
${imports if imports else ""}
|
||||||
|
|
||||||
|
revision = ${repr(up_revision)}
|
||||||
|
down_revision = ${repr(down_revision)}
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
${upgrades if upgrades else "pass"}
|
${upgrades if upgrades else "pass"}
|
||||||
|
|
||||||
|
|||||||
34
migrations/versions/0119_add_email_reply_to.py
Normal file
34
migrations/versions/0119_add_email_reply_to.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
"""
|
||||||
|
|
||||||
|
Revision ID: 0119_add_email_reply_to
|
||||||
|
Revises: 0118_service_sms_senders
|
||||||
|
Create Date: 2017-09-07 15:29:49.087143
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
revision = '0119_add_email_reply_to'
|
||||||
|
down_revision = '0118_service_sms_senders'
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table('service_email_reply_to',
|
||||||
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column('email_address', sa.Text(), nullable=False),
|
||||||
|
sa.Column('is_default', sa.Boolean(), nullable=False),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
op.f('ix_service_email_reply_to_service_id'), 'service_email_reply_to', ['service_id'], unique=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_index(op.f('ix_service_email_reply_to_service_id'), table_name='service_email_reply_to')
|
||||||
|
op.drop_table('service_email_reply_to')
|
||||||
Reference in New Issue
Block a user