Python源码示例:sqlalchemy.dialects.postgresql.TIMESTAMP
示例1
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('client_scope',
sa.Column('client_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('scope_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['client_id'], ['client.id'], name='client_scope_client_id_fkey', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['scope_id'], ['scope.id'], name='client_scope_scope_id_fkey', ondelete='CASCADE'),
sa.PrimaryKeyConstraint('client_id', 'scope_id', name='client_scope_pkey')
)
op.create_table('scope',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('name', sa.VARCHAR(length=128), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('id', name='scope_pkey'),
sa.UniqueConstraint('name', name='scope_name_key')
)
# ### end Alembic commands ###
示例2
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('key_value_store',
sa.Column('id', sa.BigInteger(), nullable=False),
sa.Column('key', sa.Text(), nullable=False),
sa.Column('value', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.PrimaryKeyConstraint('id')
)
print("Creating index")
op.create_index(op.f('ix_key_value_store_key'), 'key_value_store', ['key'], unique=True)
print("Applying not-null constraing")
op.alter_column('nu_release_item', 'release_date',
existing_type=postgresql.TIMESTAMP(),
nullable=False)
# ### end Alembic commands ###
示例3
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('organisation', 'system_blockchain_address')
op.create_table('spend_approvals',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('eth_send_task_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('approval_task_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('token_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('giving_transfer_account_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('receiving_transfer_account_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['giving_transfer_account_id'], ['transfer_account.id'], name='spend_approvals_giving_transfer_account_id_fkey'),
sa.ForeignKeyConstraint(['receiving_transfer_account_id'], ['transfer_account.id'], name='spend_approvals_receiving_transfer_account_id_fkey'),
sa.ForeignKeyConstraint(['token_id'], ['token.id'], name='spend_approvals_token_id_fkey'),
sa.PrimaryKeyConstraint('id', name='spend_approvals_pkey')
)
op.drop_table('spend_approval')
# ### end Alembic commands ###
示例4
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('chatbot_state_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.create_foreign_key('user_chatbot_state_id_fkey', 'user', 'chatbot_state', ['chatbot_state_id'], ['id'])
op.create_table('chatbot_state',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('transfer_initialised', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column('transfer_amount', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('prev_pin_failures', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('last_accessed', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('provider_message_id', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('target_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name='chatbot_state_pkey')
)
# ### end Alembic commands ###
示例5
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('targeting_survey_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.create_foreign_key('user_targeting_survey_id_fkey', 'user', 'targeting_survey', ['targeting_survey_id'], ['id'])
op.create_table('targeting_survey',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('number_people_household', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('number_below_adult_age_household', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('number_people_women_household', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('number_people_men_household', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('number_people_work_household', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('disabilities_household', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('long_term_illnesses_household', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name='targeting_survey_pkey')
)
# ### end Alembic commands ###
示例6
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('blockchain_transaction',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('submitted_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('added_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('hash', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('credit_transfer_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('block', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('status', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('transaction_type', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('message', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('signing_blockchain_address_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('nonce', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('has_output_txn', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column('is_bitcoin', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['credit_transfer_id'], ['credit_transfer.id'], name='blockchain_transaction_credit_transfer_id_fkey'),
sa.ForeignKeyConstraint(['signing_blockchain_address_id'], ['blockchain_address.id'], name='blockchain_transaction_signing_blockchain_address_id_fkey'),
sa.PrimaryKeyConstraint('id', name='blockchain_transaction_pkey')
)
# ### end Alembic commands ###
示例7
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('user', 'last_name')
op.drop_column('user', 'first_name')
op.add_column('transfer_account', sa.Column('vendor_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('first_name', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('last_name', sa.VARCHAR(), autoincrement=False, nullable=True))
op.create_foreign_key('transfer_account_vendor_id_fkey', 'transfer_account', 'transfer_account', ['vendor_id'], ['id'])
op.drop_column('transfer_account', 'payable_period_type')
op.drop_column('transfer_account', 'payable_period_length')
op.drop_column('transfer_account', 'payable_epoch')
op.drop_column('transfer_account', 'name')
op.drop_column('transfer_account', 'is_vendor')
op.create_table('vendor',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('payable_period_type', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('payable_period_length', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name='vendor_pkey')
)
# ### end Alembic commands ###
示例8
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('transfer_account', sa.Column('chat_transfer_amount', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('chat_prev_pin_failures', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('secret', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('chat_last_accessed', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('pin', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('chat_target_account_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('nfc_card_id', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('facebook_psid', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('chat_source_preference', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('qr_code', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('_phone', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('transfer_account', sa.Column('chat_transfer_initialised', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.drop_constraint(None, 'transfer_account', type_='foreignkey')
op.drop_column('transfer_account', 'vendor_id')
op.drop_table('vendor')
# ### end Alembic commands ###
示例9
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('referral',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('first_name', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('last_name', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('reason', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('_phone', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('referring_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['referring_user_id'], ['user.id'], name='referral_referring_user_id_fkey'),
sa.PrimaryKeyConstraint('id', name='referral_pkey')
)
# ### end Alembic commands ###
示例10
def downgrade():
op.create_table(
"project_members",
sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("project_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column(
"date_joined", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
),
sa.Column("is_lead", sa.BOOLEAN(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["project_id"], ["projects.id"], name="project_members_project_id_fkey"
),
sa.ForeignKeyConstraint(
["user_id"], ["users.id"], name="project_members_user_id_fkey"
),
)
op.drop_index(
op.f("ix_project_memberships_is_lead"), table_name="project_memberships"
)
op.drop_table("project_memberships")
示例11
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('monthly_billing',
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('service_id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('notification_type', postgresql.ENUM('email', 'sms', 'letter', name='notification_type'), autoincrement=False, nullable=False),
sa.Column('monthly_totals', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False),
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('start_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('end_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['service_id'], ['services.id'], name='monthly_billing_service_id_fkey'),
sa.PrimaryKeyConstraint('id', name='monthly_billing_pkey'),
sa.UniqueConstraint('service_id', 'start_date', 'notification_type', name='uix_monthly_billing')
)
op.create_index('ix_monthly_billing_service_id', 'monthly_billing', ['service_id'], unique=False)
# ### end Alembic commands ###
示例12
def downgrade():
op.create_table('job_statistics',
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('job_id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('emails_sent', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('emails_delivered', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('emails_failed', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('sms_sent', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('sms_delivered', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('sms_failed', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('letters_sent', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('letters_failed', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('sent', sa.BIGINT(), autoincrement=False, nullable=True),
sa.Column('delivered', sa.BIGINT(), autoincrement=False, nullable=True),
sa.Column('failed', sa.BIGINT(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['job_id'], ['jobs.id'], name='job_statistics_job_id_fkey'),
sa.PrimaryKeyConstraint('id', name='job_statistics_pkey')
)
示例13
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint("fk_templates_created_by_id", 'templates', type_='foreignkey')
op.drop_index(op.f('ix_templates_created_by_id'), table_name='templates')
op.drop_column('templates', 'version')
op.drop_column('templates', 'created_by_id')
op.alter_column('api_keys_history', 'created_by_id',
existing_type=postgresql.UUID(),
nullable=True)
op.alter_column('api_keys_history', 'created_at',
existing_type=postgresql.TIMESTAMP(),
nullable=True)
op.drop_index(op.f('ix_templates_history_service_id'), table_name='templates_history')
op.drop_index(op.f('ix_templates_history_created_by_id'), table_name='templates_history')
op.drop_table('templates_history')
### end Alembic commands ###
示例14
def downgrade():
op.drop_table('letter_rates')
op.create_table('letter_rates',
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('valid_from', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('id', name='letter_rates_pkey'),
postgresql_ignore_search_path=False
)
op.create_table('letter_rate_details',
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('letter_rate_id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('page_total', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('rate', sa.NUMERIC(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['letter_rate_id'], ['letter_rates.id'],
name='letter_rate_details_letter_rate_id_fkey'),
sa.PrimaryKeyConstraint('id', name='letter_rate_details_pkey')
)
示例15
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.get_bind()
query = 'update templates_history set created_by_id = ' \
'(select created_by_id from templates where templates.id = templates_history.id) ' \
'where created_by_id is null'
op.execute(query)
op.execute('update templates_history set archived = False')
op.alter_column('api_keys_history', 'created_at',
existing_type=postgresql.TIMESTAMP(),
nullable=False)
op.alter_column('api_keys_history', 'created_by_id',
existing_type=postgresql.UUID(),
nullable=False)
op.alter_column('templates_history', 'archived',
existing_type=sa.BOOLEAN(),
nullable=False)
op.alter_column('templates_history', 'created_by_id',
existing_type=postgresql.UUID(),
nullable=False)
### end Alembic commands ###
示例16
def downgrade():
op.create_table('dm_datetime',
sa.Column('bst_date', sa.DATE(), autoincrement=False, nullable=False),
sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('month_name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('day', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('bst_day', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('day_of_year', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('week_day_name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('calendar_week', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('quartal', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('year_quartal', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('year_month', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('year_calendar_week', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('financial_year', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('utc_daytime_start', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('utc_daytime_end', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('bst_date', name='dm_datetime_pkey')
)
op.create_index('ix_dm_datetime_yearmonth', 'dm_datetime', ['year', 'month'], unique=False)
op.create_index('ix_dm_datetime_bst_date', 'dm_datetime', ['bst_date'], unique=False)
示例17
def downgrade():
op.add_column('service_permissions',
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.create_table('template_statistics',
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('service_id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('template_id', postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column('usage_count', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('day', sa.DATE(), autoincrement=False, nullable=False),
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['service_id'], ['services.id'],
name='template_statistics_service_id_fkey'),
sa.ForeignKeyConstraint(['template_id'], ['templates.id'],
name='template_statistics_template_id_fkey'),
sa.PrimaryKeyConstraint('id', name='template_statistics_pkey')
)
示例18
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"task",
sa.Column(
"date_created", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
),
sa.Column(
"date_modified", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
),
sa.Column("id", sa.VARCHAR(length=36), autoincrement=False, nullable=False),
sa.Column("name", sa.VARCHAR(length=128), autoincrement=False, nullable=True),
sa.Column(
"description", sa.VARCHAR(length=128), autoincrement=False, nullable=True
),
sa.Column("failed", sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column("complete", sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint("id", name="task_pkey"),
)
op.create_index("ix_task_name", "task", ["name"], unique=False)
# ### end Alembic commands ###
示例19
def downgrade():
op.add_column(
"update",
sa.Column(
"time_window", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
)
op.add_column(
"update",
sa.Column("updated", sa.BOOLEAN(), autoincrement=False, nullable=False),
)
op.add_column(
"update", sa.Column("count", sa.INTEGER(), autoincrement=False, nullable=False)
)
op.create_unique_constraint(
"one_update_per_time_window", "update", ["poll_id", "time_window"]
)
op.drop_constraint("one_update_per_poll", "update", type_="unique")
op.drop_column("update", "next_update")
示例20
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('package', sa.Column('last_resolution_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.create_table('resolution_result',
sa.Column('id', sa.INTEGER(), server_default="nextval('resolution_result_id_seq'::regclass)", nullable=False),
sa.Column('package_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('resolved', sa.BOOLEAN(), autoincrement=False, nullable=False),
sa.Column('repo_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('generated', postgresql.TIMESTAMP(), server_default='now()', autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['package_id'], [u'package.id'], name=u'resolution_result_package_id_fkey', ondelete=u'CASCADE'),
sa.PrimaryKeyConstraint('id', name=u'resolution_result_pkey'),
postgresql_ignore_search_path=False
)
op.create_table('resolution_result_element',
sa.Column('id', sa.INTEGER(), server_default="nextval('resolution_result_element_id_seq'::regclass)", nullable=False),
sa.Column('resolution_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('problem', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['resolution_id'], [u'resolution_result.id'], name=u'resolution_result_element_resolution_id_fkey', ondelete=u'CASCADE'),
sa.PrimaryKeyConstraint('id', name=u'resolution_result_element_pkey')
)
op.drop_index('ix_resolution_problem_package_id', table_name='resolution_problem')
op.drop_table('resolution_problem')
op.drop_table('repo')
### end Alembic commands ###
示例21
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('messages',
sa.Column('guild_id', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('channel_id', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('message_id', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('content', sa.TEXT(), autoincrement=False, nullable=False),
sa.Column('author', sa.TEXT(), autoincrement=False, nullable=False),
sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('edited_timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('mentions', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('attachments', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('embeds', sa.TEXT(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('message_id', name='messages_pkey')
)
# ### end Alembic commands ###
示例22
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('unavailable_room_report',
sa.Column('record_id', sa.Integer(), nullable=False),
sa.Column('room_id', sa.String(), nullable=True),
sa.Column('date', sa.Date(), nullable=True),
sa.Column('time', sa.String(length=4), nullable=True),
sa.Column('reporter', sa.String(length=15), nullable=True),
sa.Column('reporter_type', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('record_id'),
sa.UniqueConstraint('room_id', 'date', 'time', 'reporter', 'reporter_type', name='unavailable_room_report_uniq')
)
op.drop_index('idx_token', table_name='calendar_tokens')
op.alter_column('identity_verify_requests', 'create_time',
existing_type=postgresql.TIMESTAMP(timezone=True),
nullable=True)
op.create_index(op.f('ix_simple_passwords_time'), 'simple_passwords', ['time'], unique=False)
op.drop_index('idx_host_time', table_name='visit_tracks')
op.create_index('idx_host_time', 'visit_tracks', ['host_id', 'last_visit_time'], unique=False)
# ### end Alembic commands ###
示例23
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index('idx_host_time', table_name='visit_tracks')
op.create_index('idx_host_time', 'visit_tracks', ['host_id', 'last_visit_time'], unique=True)
op.drop_index(op.f('ix_simple_passwords_time'), table_name='simple_passwords')
op.alter_column('identity_verify_requests', 'create_time',
existing_type=postgresql.TIMESTAMP(timezone=True),
nullable=False)
op.create_index('idx_token', 'calendar_tokens', ['token'], unique=True)
op.drop_table('unavailable_room_report')
# ### end Alembic commands ###
示例24
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('use_of_force_incidents', sa.Column('status', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('use_of_force_incidents', sa.Column('day_of_week', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('use_of_force_incidents', sa.Column('received_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.add_column('use_of_force_incidents', sa.Column('citizen_injured', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('use_of_force_incidents', sa.Column('citizen_weapon', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('use_of_force_incidents', sa.Column('citizen_hospitalized', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('use_of_force_incidents', sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('use_of_force_incidents', sa.Column('hour', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('use_of_force_incidents', sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=True))
op.alter_column('use_of_force_incidents', 'department_id',
existing_type=sa.INTEGER(),
nullable=True)
op.drop_column('use_of_force_incidents', 'shift')
op.drop_column('use_of_force_incidents', 'resident_weapon_used')
op.drop_column('use_of_force_incidents', 'resident_resist_type')
op.drop_column('use_of_force_incidents', 'resident_race')
op.drop_column('use_of_force_incidents', 'resident_injured')
op.drop_column('use_of_force_incidents', 'resident_hospitalized')
op.drop_column('use_of_force_incidents', 'precinct')
op.drop_column('use_of_force_incidents', 'officer_race')
op.drop_column('use_of_force_incidents', 'officer_force_type')
op.drop_column('use_of_force_incidents', 'office_weapon_used')
op.drop_column('use_of_force_incidents', 'division')
op.drop_column('use_of_force_incidents', 'beat')
### end Alembic commands ###
示例25
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('use_of_force_incidents', sa.Column('received_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
### end Alembic commands ###
示例26
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('use_of_force_incidents', 'resident_condition')
op.drop_column('use_of_force_incidents', 'officer_condition')
op.create_table('citizen_complaint',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('department_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('opaque_id', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
sa.Column('occured_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('division', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('precinct', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('shift', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('beat', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('disposition', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('census_tract', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('resident_race', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('officer_race', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('resident_sex', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('officer_sex', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('officer_identifier', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('officer_years_of_service', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('category', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('officer_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column('resident_age', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['department_id'], ['departments.id'], name='citizen_complaint_department_id_fkey'),
sa.PrimaryKeyConstraint('id', name='citizen_complaint_pkey')
)
op.drop_table('citizen_complaints')
op.drop_table('officer_involved_shootings')
### end Alembic commands ###
示例27
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('task_result', sa.Column('traceback', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('task_result', sa.Column('task_id', sa.VARCHAR(length=155), autoincrement=False, nullable=True))
op.add_column('task_result', sa.Column('date_done', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.add_column('task_result', sa.Column('status', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
op.add_column('task_result', sa.Column('result', postgresql.BYTEA(), autoincrement=False, nullable=True))
op.drop_constraint(None, 'task_result', type_='foreignkey')
op.create_unique_constraint('task_result_task_id_key', 'task_result', ['task_id'])
op.drop_index(op.f('ix_task_result_celery_taskmeta_id'), table_name='task_result')
op.drop_column('task_result', 'celery_taskmeta_id')
op.drop_table('celery_tasksetmeta')
op.drop_table('celery_taskmeta')
# ### end Alembic commands ###
示例28
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('activation_code', 'expired',
existing_type=postgresql.TIMESTAMP(),
nullable=False)
# ### end Alembic commands ###
示例29
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('activation_code', 'expired',
existing_type=postgresql.TIMESTAMP(),
nullable=True)
# ### end Alembic commands ###
示例30
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('partner',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('email', sa.VARCHAR(length=128), autoincrement=False, nullable=True),
sa.Column('name', sa.VARCHAR(length=128), autoincrement=False, nullable=True),
sa.Column('website', sa.VARCHAR(length=1024), autoincrement=False, nullable=True),
sa.Column('additional_information', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='partner_user_id_fkey', ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name='partner_pkey')
)
# ### end Alembic commands ###