Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change personal_email to email_address #40

Merged
merged 2 commits into from Jun 7, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

Make change atomic and preserve data

  • Loading branch information...
jonodrew committed Jun 7, 2019
commit 13ad95a3d6893e3eb25f01e8b4c7110c83a34241
@@ -42,11 +42,12 @@ class Ethnicity(db.Model):

class Candidate(db.Model):
id = db.Column(db.Integer, primary_key=True)
email_address = db.Column(db.String(120), unique=True)
personal_email = db.Column(db.String(120), unique=True)
joining_date = db.Column(db.Date())
completed_fast_stream = db.Column(db.Boolean())
first_name = db.Column(db.String(128))
last_name = db.Column(db.String(128))
email_address = db.Column(db.String(120), unique=True)

joining_grade = db.Column(db.ForeignKey('grade.id'))
ethnicity_id = db.Column(db.ForeignKey('ethnicity.id'))
@@ -1,28 +1,31 @@
"""Change personal_email to email_address
Revision ID: f3904e94e2ed
Revision ID: 2115ecb81393
Revises: 5995ecd39f79
Create Date: 2019-06-07 14:50:36.217189
Create Date: 2019-06-07 17:38:33.912700
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f3904e94e2ed'
revision = '2115ecb81393'
down_revision = '5995ecd39f79'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(table_name='candidate', column_name='personal_email', new_column_name='email_address')
op.add_column('candidate', sa.Column('email_address', sa.String(length=120), nullable=True))
op.create_unique_constraint(None, 'candidate', ['email_address'])
op.execute("UPDATE candidate SET email_address = personal_email;")
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(table_name='candidate', column_name='email_address', new_column_name='personal_email')
op.drop_constraint('candidate_email_address_key', 'candidate', type_='unique')
op.drop_column('candidate', 'email_address')
# ### end Alembic commands ###
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.