Skip to content

Commit

Permalink
46 - Migrate Again
Browse files Browse the repository at this point in the history
  • Loading branch information
codingforentrepreneurs committed Mar 11, 2019
1 parent e52416b commit da69781
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
8 changes: 4 additions & 4 deletions landing/home/models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import datetime
from landing import db

from sqlalchemy import event

class EmailSignup(db.Model):
id = db.Column(db.Integer, primary_key=True) # primary_key
full_name = db.Column(db.String(120), nullable=True)
content = db.Column(
db.Text,
nullable=True
)
email = db.Column(db.String(120), unique=True, nullable=False)
timestamp = db.Column(db.DateTime, index=True, default=datetime.datetime.utcnow)
updated = db.Column(db.DateTime, index=True, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow)


def save(self, commit=True):
# create and update
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""empty message
Revision ID: 1c9634fb2c62
Revision ID: 0bc39a029870
Revises:
Create Date: 2019-03-11 15:37:41.359510
Create Date: 2019-03-11 15:46:36.144388
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1c9634fb2c62'
revision = '0bc39a029870'
down_revision = None
branch_labels = None
depends_on = None
Expand All @@ -21,7 +21,6 @@ def upgrade():
op.create_table('email_signup',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('full_name', sa.String(length=120), nullable=True),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('email', sa.String(length=120), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
Expand Down
34 changes: 34 additions & 0 deletions migrations/versions/d64db672b5ce_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""empty message
Revision ID: d64db672b5ce
Revises: 0bc39a029870
Create Date: 2019-03-11 15:46:47.427682
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'd64db672b5ce'
down_revision = '0bc39a029870'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('email_signup', sa.Column('timestamp', sa.DateTime(), nullable=True))
op.add_column('email_signup', sa.Column('updated', sa.DateTime(), nullable=True))
op.create_index(op.f('ix_email_signup_timestamp'), 'email_signup', ['timestamp'], unique=False)
op.create_index(op.f('ix_email_signup_updated'), 'email_signup', ['updated'], unique=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_email_signup_updated'), table_name='email_signup')
op.drop_index(op.f('ix_email_signup_timestamp'), table_name='email_signup')
op.drop_column('email_signup', 'updated')
op.drop_column('email_signup', 'timestamp')
# ### end Alembic commands ###

0 comments on commit da69781

Please sign in to comment.