Python sqlalchemy.dialects.postgresql.TIMESTAMP Examples

The following are 30 code examples of sqlalchemy.dialects.postgresql.TIMESTAMP(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sqlalchemy.dialects.postgresql , or try the search function .
Example #1
Source File: 0210_remove_monthly_billing.py    From notifications-api with MIT License 6 votes vote down vote up
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 ### 
Example #2
Source File: 3c523b7fe87d_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
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 ### 
Example #3
Source File: c1bae50735e8_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
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 ### 
Example #4
Source File: 026e6bde589e_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
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 ### 
Example #5
Source File: ba9c2a8e7338_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
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 ### 
Example #6
Source File: 1c89fa61f23e_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
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 ### 
Example #7
Source File: 1083bb6545c9_.py    From website with MIT License 6 votes vote down vote up
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") 
Example #8
Source File: 778e1348250b_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
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 ### 
Example #9
Source File: c9db3658816a_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
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 ### 
Example #10
Source File: 00042_49308bd51717_kvstore_table.py    From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 ### 
Example #11
Source File: 20190401_19-03-55__revert_task_table_creation.py    From busy-beaver with MIT License 6 votes vote down vote up
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 ### 
Example #12
Source File: 2019_10_15_7783c1dc58f7_better_update_handling.py    From ultimate-poll-bot with MIT License 6 votes vote down vote up
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") 
Example #13
Source File: 0175_drop_job_statistics_table.py    From notifications-api with MIT License 6 votes vote down vote up
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')
    ) 
Example #14
Source File: 551c4e6d4a8b_.py    From app with MIT License 6 votes vote down vote up
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 ### 
Example #15
Source File: 0007_template_history.py    From notifications-api with MIT License 6 votes vote down vote up
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 ### 
Example #16
Source File: 0151_refactor_letter_rates.py    From notifications-api with MIT License 6 votes vote down vote up
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')
                    ) 
Example #17
Source File: 5576cfc14700_get_rid_of_resolution_result.py    From koschei with GNU General Public License v2.0 6 votes vote down vote up
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 ### 
Example #18
Source File: 0015_fix_template_data.py    From notifications-api with MIT License 6 votes vote down vote up
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 ### 
Example #19
Source File: d4841aeeb072_.py    From gitlab-tools with GNU General Public License v3.0 6 votes vote down vote up
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 ### 
Example #20
Source File: 0307_delete_dm_datetime.py    From notifications-api with MIT License 6 votes vote down vote up
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) 
Example #21
Source File: 0107_drop_template_stats.py    From notifications-api with MIT License 6 votes vote down vote up
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')
                    ) 
Example #22
Source File: 52271b243ba2_remove_messages_table_for_good.py    From Titan with GNU Affero General Public License v3.0 6 votes vote down vote up
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 ### 
Example #23
Source File: db9e3d6db63c_alter_db.py    From travelcrm with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('resource', 'modifydt')
    op.create_table('resource_log',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('resource_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('employee_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('comment', sa.VARCHAR(length=512), autoincrement=False, nullable=True),
    sa.Column('modifydt', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['employee_id'], [u'employee.id'], name=u'fk_employee_id_resource_log', onupdate=u'CASCADE', ondelete=u'CASCADE'),
    sa.ForeignKeyConstraint(['resource_id'], [u'resource.id'], name=u'fk_resource_id_resource_log', onupdate=u'CASCADE', ondelete=u'CASCADE'),
    sa.PrimaryKeyConstraint('id', name=u'resource_log_pkey')
    )
    ### end Alembic commands ### 
Example #24
Source File: 20200705_23-36-02__delete_slack_app_home_opened_table.py    From busy-beaver with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "slack_app_home_opened",
        sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column(
            "date_created", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
        ),
        sa.Column(
            "date_modified", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
        ),
        sa.Column("installation_id", sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column(
            "slack_id", sa.VARCHAR(length=30), autoincrement=False, nullable=False
        ),
        sa.Column("count", sa.INTEGER(), autoincrement=False, nullable=False),
        sa.ForeignKeyConstraint(
            ["installation_id"], ["slack_installation.id"], name="fk_installation_id"
        ),
        sa.PrimaryKeyConstraint("id", name="slack_app_home_opened_pkey"),
    )
    op.create_index(
        "ix_slack_app_home_opened_slack_id",
        "slack_app_home_opened",
        ["slack_id"],
        unique=False,
    )
    op.create_index(
        "ix_slack_app_home_opened_installation_id",
        "slack_app_home_opened",
        ["installation_id"],
        unique=False,
    )
    # ### end Alembic commands ### 
Example #25
Source File: util.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def last_update_time() -> sa.Column:
    """A timestamp column set to CURRENT_TIMESTAMP on update.

    Return a column containing the time that a record was last updated.

    :return: a SQLAlchemy Column for a datetime with time zone auto-updating
             column
    """
    return sa.Column(
        pg.TIMESTAMP(timezone=True),
        nullable=False,
        server_default=current_timestamp(),
        onupdate=current_timestamp(),
    ) 
Example #26
Source File: 20200419_04-49-50__remove_token_auth_table.py    From busy-beaver with MIT License 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "api_user",
        sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column(
            "date_created", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
        ),
        sa.Column(
            "date_modified", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
        ),
        sa.Column(
            "username", sa.VARCHAR(length=255), autoincrement=False, nullable=False
        ),
        sa.Column("token", sa.VARCHAR(length=255), autoincrement=False, nullable=False),
        sa.Column(
            "role",
            sa.VARCHAR(length=255),
            server_default=sa.text("'user'::character varying"),
            autoincrement=False,
            nullable=False,
        ),
        sa.PrimaryKeyConstraint("id", name="api_user_pkey"),
    )

    op.add_column(
        "task", sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=True)
    )
    op.create_foreign_key("fk_task_user_id", "task", "api_user", ["user_id"], ["id"])
    # ### end Alembic commands ### 
Example #27
Source File: 32518998055d_.py    From pgcontents with Apache License 2.0 5 votes vote down vote up
def downgrade():
    op.create_table(
        'checkpoints',
        sa.Column(
            'id',
            sa.INTEGER(),
            server_default=sa.text(
                u"nextval('pgcontents.checkpoints_id_seq'::regclass)"
            ),
            nullable=False,
        ),
        sa.Column(
            'file_id',
            sa.INTEGER(),
            autoincrement=False,
            nullable=False,
        ),
        sa.Column(
            'created_at',
            postgresql.TIMESTAMP(),
            autoincrement=False,
            nullable=False
        ),
        sa.ForeignKeyConstraint(
            ['file_id'],
            [u'pgcontents.files.id'],
            name=u'checkpoints_file_id_fkey',
            onupdate=u'CASCADE',
            ondelete=u'CASCADE'
        ),
        sa.PrimaryKeyConstraint(
            'id',
            name=u'checkpoints_pkey'
        ),
        schema='pgcontents',
    ) 
Example #28
Source File: a90076b18837_tasks_and_shift.py    From gamification-engine with MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('tasks',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('entry_name', sa.String(length=100), nullable=True),
    sa.Column('task_name', sa.String(length=100), nullable=False),
    sa.Column('config', sa.JSON(), nullable=True),
    sa.Column('cron', sa.String(length=100), nullable=True),
    sa.Column('is_removed', sa.Boolean(), nullable=False),
    sa.Column('is_auto_created', sa.Boolean(), nullable=False),
    sa.Column('is_manually_modified', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_tasks'))
    )
    op.create_index(op.f('ix_tasks_entry_name'), 'tasks', ['entry_name'], unique=False)
    op.create_index(op.f('ix_tasks_is_auto_created'), 'tasks', ['is_auto_created'], unique=False)
    op.create_index(op.f('ix_tasks_is_removed'), 'tasks', ['is_removed'], unique=False)
    op.create_index(op.f('ix_tasks_is_manually_modified'), 'tasks', ['is_manually_modified'], unique=False)
    op.create_index(op.f('ix_tasks_task_name'), 'tasks', ['task_name'], unique=False)
    op.create_table('taskexecutions',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('task_id', sa.Integer(), nullable=False),
    sa.Column('planned_at', postgresql.TIMESTAMP(timezone=True), nullable=False),
    sa.Column('locked_at', postgresql.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('finished_at', postgresql.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('canceled_at', postgresql.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('log', sa.String(), nullable=True),
    sa.Column('success', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], name=op.f('fk_taskexecutions_task_id_tasks'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_taskexecutions'))
    )
    op.create_index(op.f('ix_taskexecutions_canceled_at'), 'taskexecutions', ['canceled_at'], unique=False)
    op.create_index(op.f('ix_taskexecutions_finished_at'), 'taskexecutions', ['finished_at'], unique=False)
    op.create_index(op.f('ix_taskexecutions_locked_at'), 'taskexecutions', ['locked_at'], unique=False)
    op.create_index(op.f('ix_taskexecutions_planned_at'), 'taskexecutions', ['planned_at'], unique=False)
    op.create_index(op.f('ix_taskexecutions_success'), 'taskexecutions', ['success'], unique=False)
    op.create_index(op.f('ix_taskexecutions_task_id'), 'taskexecutions', ['task_id'], unique=False)
    op.add_column('achievements', sa.Column('evaluation_shift', sa.Integer(), nullable=True))
    ### end Alembic commands ### 
Example #29
Source File: c4e6d5863a94_removing_unused_tables_adding_tag_index.py    From pygameweb with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_index('public_tags_value1_idx', 'tags', ['value'], unique=False)
    op.create_index('public_tags_project_id0_idx', 'tags', ['project_id'], unique=False)
    op.drop_index(op.f('ix_tags_value'), table_name='tags')
    op.drop_index(op.f('ix_tags_project_id'), table_name='tags')
    op.create_table('wikicomment',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('link', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('users_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('datetimeon', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('content', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='wikicomment_pkey')
    )
    ### end Alembic commands ### 
Example #30
Source File: 8acbad111ef6_queue_table_for_pq.py    From pygameweb with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('queue',
    sa.Column('id', sa.BIGINT(), nullable=False),
    sa.Column('enqueued_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=False),
    sa.Column('dequeued_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('expected_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('schedule_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('q_name', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('priority_idx', 'queue', ['schedule_at', 'expected_at'], unique=False)
    # ### end Alembic commands ###