"""create tables

Revision ID: 6fb351569d30
Revises: 4<PASSWORD>1ff38b
Create Date: 2019-05-06 21:59:43.998735

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '4<PASSWORD>'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('account',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('purpose', sa.String(length=64), nullable=True),
    sa.Column('status', sa.Enum('Active', 'Closed', name='accountstatus', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('institution', sa.String(length=64), nullable=True),
    sa.Column('sort_code', sa.String(length=64), nullable=True),
    sa.Column('account_no', sa.String(length=64), nullable=True),
    sa.Column('BIC', sa.String(length=64), nullable=True),
    sa.Column('IBAN', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('address',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('address1', sa.String(length=64), nullable=True),
    sa.Column('address2', sa.String(length=64), nullable=True),
    sa.Column('address3', sa.String(length=64), nullable=True),
    sa.Column('county', sa.String(length=64), nullable=True),
    sa.Column('countryISO', sa.String(length=64), nullable=True),
    sa.Column('eircode', sa.String(length=64), nullable=True),
    sa.Column('telephone', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('household',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('address1', sa.String(length=64), nullable=True),
    sa.Column('address2', sa.String(length=64), nullable=True),
    sa.Column('address3', sa.String(length=64), nullable=True),
    sa.Column('county', sa.String(length=64), nullable=True),
    sa.Column('eircode', sa.String(length=64), nullable=True),
    sa.Column('telephone', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('nominal_account',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=64), nullable=True),
    sa.Column('SOFA_heading', sa.Enum('Donations_and_legacies', 'Income_from_charitable_activities', 'Other_trading_activities', 'Investments', 'Other_income', 'Raising_funds', 'Expenditure_on_charitable_activities', 'Other_expenditure', name='nominalaccountsofaheading', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('category', sa.Enum('Income', 'Expenditure', 'Fixed_assets', 'Current_assets', 'Liabilities', name='nominalaccountcategory', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('sub_category', sa.Enum('Tangible_assets', 'Investments', 'Debtors', 'Cash_at_bank_and_in_hand', 'Creditors_Amounts_falling_due_in_one_year', 'Creditors_Amounts_falling_due_after_more_than_one_year', 'Agency_accounts', 'Reserves', name='nominalaccountsubcategory', schema='glod', inherit_schema=True), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('organisation',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('category', sa.Enum('Household', 'NonLocalHousehold', 'Company', 'Charity', 'Government', name='organisationcategory', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('status', sa.Enum('Active', 'Inactive', name='organisationstatus', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('parishioner',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('surname', sa.String(length=64), nullable=True),
    sa.Column('first_name', sa.String(length=64), nullable=True),
    sa.Column('title', sa.String(length=64), nullable=True),
    sa.Column('status', sa.String(length=64), nullable=True),
    sa.Column('main_contact', sa.String(length=64), nullable=True),
    sa.Column('household_ref_no', sa.Integer(), nullable=True),
    sa.Column('mobile', sa.String(length=64), nullable=True),
    sa.Column('other', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('gdpr_response', sa.String(length=64), nullable=True),
    sa.Column('by_email', sa.String(length=64), nullable=True),
    sa.Column('by_phone', sa.String(length=64), nullable=True),
    sa.Column('by_post', sa.String(length=64), nullable=True),
    sa.Column('news', sa.String(length=64), nullable=True),
    sa.Column('finance', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('subject',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('select_vestry_summary', sa.String(length=64), nullable=True),
    sa.Column('easter_vestry_summary', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('fund',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('restriction', sa.Enum('Unrestricted', 'Restricted', 'Endowment', name='fundrestriction', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('is_parish_fund', sa.Boolean(), nullable=True),
    sa.Column('is_realised', sa.Boolean(), nullable=True),
    sa.Column('account_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['account_id'], ['glod.account.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('organisation_address',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('status', sa.Enum('Current', 'Prior', name='organisationaddressstatus', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('address_id', sa.Integer(), nullable=True),
    sa.Column('organisation_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['address_id'], ['glod.address.id'], ),
    sa.ForeignKeyConstraint(['organisation_id'], ['glod.organisation.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('person',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('family_name', sa.String(length=64), nullable=True),
    sa.Column('given_name', sa.String(length=64), nullable=True),
    sa.Column('title', sa.String(length=64), nullable=True),
    sa.Column('status', sa.Enum('Active', 'LostContact', 'Deceased', name='personstatus', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('mobile', sa.String(length=64), nullable=True),
    sa.Column('other_phone', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('parishioner_reference_no', sa.Integer(), nullable=True),
    sa.Column('organisation_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['organisation_id'], ['glod.organisation.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('statement_item',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('date', sa.Date(), nullable=True),
    sa.Column('details', sa.String(length=64), nullable=True),
    sa.Column('currency', sa.String(length=64), nullable=True),
    sa.Column('debit', sa.Numeric(scale=2), nullable=True),
    sa.Column('credit', sa.Numeric(scale=2), nullable=True),
    sa.Column('balance', sa.Numeric(scale=2), nullable=True),
    sa.Column('detail_override', sa.String(length=64), nullable=True),
    sa.Column('designated_balance', sa.Enum('No', 'Opening', 'Closing', name='statementitemdesignatedbalance', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('account_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['account_id'], ['glod.account.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('communication_permission',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('is_main_contact', sa.Boolean(), nullable=True),
    sa.Column('gdpr_response', sa.DateTime(), nullable=True),
    sa.Column('by_email', sa.Boolean(), nullable=True),
    sa.Column('by_phone', sa.Boolean(), nullable=True),
    sa.Column('by_post', sa.Boolean(), nullable=True),
    sa.Column('news', sa.Boolean(), nullable=True),
    sa.Column('finance', sa.Boolean(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['person_id'], ['glod.person.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('counterparty',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('bank_text', sa.String(length=64), nullable=True),
    sa.Column('name_override', sa.String(length=64), nullable=True),
    sa.Column('method', sa.String(length=64), nullable=True),
    sa.Column('has_SO_card', sa.Boolean(), nullable=True),
    sa.Column('by_email', sa.Boolean(), nullable=True),
    sa.Column('notes', sa.String(length=1024), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.Column('organisation_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['organisation_id'], ['glod.organisation.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['glod.person.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('pps',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('pps', sa.String(length=64), nullable=True),
    sa.Column('name_override', sa.String(length=64), nullable=True),
    sa.Column('notes', sa.String(length=1024), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['person_id'], ['glod.person.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('envelope',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('envelope_number', sa.Integer(), nullable=True),
    sa.Column('counterparty_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['counterparty_id'], ['glod.counterparty.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['glod.person.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('transaction',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('public_code', sa.String(length=64), nullable=True),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('month', sa.Integer(), nullable=True),
    sa.Column('day', sa.Integer(), nullable=True),
    sa.Column('payment_method', sa.Enum('BankCharges', 'BankTax', 'BillpayOnline', 'CashLodgmentEnvelopes', 'CashLodgmentOther', 'CashLodgmentPlate', 'Cheque', 'DirectDebit', 'DirectPayment', 'DirectTransfer', 'InBranch', 'StandingOrderMonthly', 'StandingOrderOther', 'StandingOrderQuarterly', 'StandingOrders', 'UnrealisedGainLoss', name='paymentmethod', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('description', sa.String(length=1024), nullable=True),
    sa.Column('amount', sa.Numeric(scale=2), nullable=True),
    sa.Column('income_expenditure', sa.Enum('Income', 'Expenditure', name='incomeexpenditure', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('FY', sa.String(length=64), nullable=True),
    sa.Column('comments', sa.String(length=1024), nullable=True),
    sa.Column('counterparty_id', sa.Integer(), nullable=True),
    sa.Column('subject_id', sa.Integer(), nullable=True),
    sa.Column('fund_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['counterparty_id'], ['glod.counterparty.id'], ),
    sa.ForeignKeyConstraint(['fund_id'], ['glod.fund.id'], ),
    sa.ForeignKeyConstraint(['subject_id'], ['glod.subject.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('transaction_check',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('transaction_id', sa.Integer(), nullable=True),
    sa.Column('statement_item_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['statement_item_id'], ['glod.statement_item.id'], ),
    sa.ForeignKeyConstraint(['transaction_id'], ['glod.transaction.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('transaction_check', schema='glod')
    op.drop_table('transaction', schema='glod')
    op.drop_table('envelope', schema='glod')
    op.drop_table('pps', schema='glod')
    op.drop_table('counterparty', schema='glod')
    op.drop_table('communication_permission', schema='glod')
    op.drop_table('statement_item', schema='glod')
    op.drop_table('person', schema='glod')
    op.drop_table('organisation_address', schema='glod')
    op.drop_table('fund', schema='glod')
    op.drop_table('subject', schema='glod')
    op.drop_table('parishioner', schema='glod')
    op.drop_table('organisation', schema='glod')
    op.drop_table('nominal_account', schema='glod')
    op.drop_table('household', schema='glod')
    op.drop_table('address', schema='glod')
    op.drop_table('account', schema='glod')
    # ### end Alembic commands ###

"""create tables

Revision ID: 6fb351569d30
Revises: 4<PASSWORD>1ff38b
Create Date: 2019-05-06 21:59:43.998735

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '4<PASSWORD>'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('account',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('purpose', sa.String(length=64), nullable=True),
    sa.Column('status', sa.Enum('Active', 'Closed', name='accountstatus', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('institution', sa.String(length=64), nullable=True),
    sa.Column('sort_code', sa.String(length=64), nullable=True),
    sa.Column('account_no', sa.String(length=64), nullable=True),
    sa.Column('BIC', sa.String(length=64), nullable=True),
    sa.Column('IBAN', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('address',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('address1', sa.String(length=64), nullable=True),
    sa.Column('address2', sa.String(length=64), nullable=True),
    sa.Column('address3', sa.String(length=64), nullable=True),
    sa.Column('county', sa.String(length=64), nullable=True),
    sa.Column('countryISO', sa.String(length=64), nullable=True),
    sa.Column('eircode', sa.String(length=64), nullable=True),
    sa.Column('telephone', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('household',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('address1', sa.String(length=64), nullable=True),
    sa.Column('address2', sa.String(length=64), nullable=True),
    sa.Column('address3', sa.String(length=64), nullable=True),
    sa.Column('county', sa.String(length=64), nullable=True),
    sa.Column('eircode', sa.String(length=64), nullable=True),
    sa.Column('telephone', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('nominal_account',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('code', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=64), nullable=True),
    sa.Column('SOFA_heading', sa.Enum('Donations_and_legacies', 'Income_from_charitable_activities', 'Other_trading_activities', 'Investments', 'Other_income', 'Raising_funds', 'Expenditure_on_charitable_activities', 'Other_expenditure', name='nominalaccountsofaheading', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('category', sa.Enum('Income', 'Expenditure', 'Fixed_assets', 'Current_assets', 'Liabilities', name='nominalaccountcategory', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('sub_category', sa.Enum('Tangible_assets', 'Investments', 'Debtors', 'Cash_at_bank_and_in_hand', 'Creditors_Amounts_falling_due_in_one_year', 'Creditors_Amounts_falling_due_after_more_than_one_year', 'Agency_accounts', 'Reserves', name='nominalaccountsubcategory', schema='glod', inherit_schema=True), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('organisation',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('category', sa.Enum('Household', 'NonLocalHousehold', 'Company', 'Charity', 'Government', name='organisationcategory', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('status', sa.Enum('Active', 'Inactive', name='organisationstatus', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('parishioner',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('surname', sa.String(length=64), nullable=True),
    sa.Column('first_name', sa.String(length=64), nullable=True),
    sa.Column('title', sa.String(length=64), nullable=True),
    sa.Column('status', sa.String(length=64), nullable=True),
    sa.Column('main_contact', sa.String(length=64), nullable=True),
    sa.Column('household_ref_no', sa.Integer(), nullable=True),
    sa.Column('mobile', sa.String(length=64), nullable=True),
    sa.Column('other', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('gdpr_response', sa.String(length=64), nullable=True),
    sa.Column('by_email', sa.String(length=64), nullable=True),
    sa.Column('by_phone', sa.String(length=64), nullable=True),
    sa.Column('by_post', sa.String(length=64), nullable=True),
    sa.Column('news', sa.String(length=64), nullable=True),
    sa.Column('finance', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('subject',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('select_vestry_summary', sa.String(length=64), nullable=True),
    sa.Column('easter_vestry_summary', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('fund',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('restriction', sa.Enum('Unrestricted', 'Restricted', 'Endowment', name='fundrestriction', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('is_parish_fund', sa.Boolean(), nullable=True),
    sa.Column('is_realised', sa.Boolean(), nullable=True),
    sa.Column('account_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['account_id'], ['glod.account.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('organisation_address',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('status', sa.Enum('Current', 'Prior', name='organisationaddressstatus', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('address_id', sa.Integer(), nullable=True),
    sa.Column('organisation_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['address_id'], ['glod.address.id'], ),
    sa.ForeignKeyConstraint(['organisation_id'], ['glod.organisation.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('person',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('family_name', sa.String(length=64), nullable=True),
    sa.Column('given_name', sa.String(length=64), nullable=True),
    sa.Column('title', sa.String(length=64), nullable=True),
    sa.Column('status', sa.Enum('Active', 'LostContact', 'Deceased', name='personstatus', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('mobile', sa.String(length=64), nullable=True),
    sa.Column('other_phone', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('parishioner_reference_no', sa.Integer(), nullable=True),
    sa.Column('organisation_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['organisation_id'], ['glod.organisation.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('statement_item',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('date', sa.Date(), nullable=True),
    sa.Column('details', sa.String(length=64), nullable=True),
    sa.Column('currency', sa.String(length=64), nullable=True),
    sa.Column('debit', sa.Numeric(scale=2), nullable=True),
    sa.Column('credit', sa.Numeric(scale=2), nullable=True),
    sa.Column('balance', sa.Numeric(scale=2), nullable=True),
    sa.Column('detail_override', sa.String(length=64), nullable=True),
    sa.Column('designated_balance', sa.Enum('No', 'Opening', 'Closing', name='statementitemdesignatedbalance', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('account_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['account_id'], ['glod.account.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('communication_permission',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('is_main_contact', sa.Boolean(), nullable=True),
    sa.Column('gdpr_response', sa.DateTime(), nullable=True),
    sa.Column('by_email', sa.Boolean(), nullable=True),
    sa.Column('by_phone', sa.Boolean(), nullable=True),
    sa.Column('by_post', sa.Boolean(), nullable=True),
    sa.Column('news', sa.Boolean(), nullable=True),
    sa.Column('finance', sa.Boolean(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['person_id'], ['glod.person.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('counterparty',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('bank_text', sa.String(length=64), nullable=True),
    sa.Column('name_override', sa.String(length=64), nullable=True),
    sa.Column('method', sa.String(length=64), nullable=True),
    sa.Column('has_SO_card', sa.Boolean(), nullable=True),
    sa.Column('by_email', sa.Boolean(), nullable=True),
    sa.Column('notes', sa.String(length=1024), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.Column('organisation_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['organisation_id'], ['glod.organisation.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['glod.person.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('pps',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('pps', sa.String(length=64), nullable=True),
    sa.Column('name_override', sa.String(length=64), nullable=True),
    sa.Column('notes', sa.String(length=1024), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['person_id'], ['glod.person.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('envelope',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('envelope_number', sa.Integer(), nullable=True),
    sa.Column('counterparty_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['counterparty_id'], ['glod.counterparty.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['glod.person.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('transaction',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference_no', sa.Integer(), nullable=True),
    sa.Column('public_code', sa.String(length=64), nullable=True),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('month', sa.Integer(), nullable=True),
    sa.Column('day', sa.Integer(), nullable=True),
    sa.Column('payment_method', sa.Enum('BankCharges', 'BankTax', 'BillpayOnline', 'CashLodgmentEnvelopes', 'CashLodgmentOther', 'CashLodgmentPlate', 'Cheque', 'DirectDebit', 'DirectPayment', 'DirectTransfer', 'InBranch', 'StandingOrderMonthly', 'StandingOrderOther', 'StandingOrderQuarterly', 'StandingOrders', 'UnrealisedGainLoss', name='paymentmethod', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('description', sa.String(length=1024), nullable=True),
    sa.Column('amount', sa.Numeric(scale=2), nullable=True),
    sa.Column('income_expenditure', sa.Enum('Income', 'Expenditure', name='incomeexpenditure', schema='glod', inherit_schema=True), nullable=True),
    sa.Column('FY', sa.String(length=64), nullable=True),
    sa.Column('comments', sa.String(length=1024), nullable=True),
    sa.Column('counterparty_id', sa.Integer(), nullable=True),
    sa.Column('subject_id', sa.Integer(), nullable=True),
    sa.Column('fund_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['counterparty_id'], ['glod.counterparty.id'], ),
    sa.ForeignKeyConstraint(['fund_id'], ['glod.fund.id'], ),
    sa.ForeignKeyConstraint(['subject_id'], ['glod.subject.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    op.create_table('transaction_check',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('transaction_id', sa.Integer(), nullable=True),
    sa.Column('statement_item_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['statement_item_id'], ['glod.statement_item.id'], ),
    sa.ForeignKeyConstraint(['transaction_id'], ['glod.transaction.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='glod'
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('transaction_check', schema='glod')
    op.drop_table('transaction', schema='glod')
    op.drop_table('envelope', schema='glod')
    op.drop_table('pps', schema='glod')
    op.drop_table('counterparty', schema='glod')
    op.drop_table('communication_permission', schema='glod')
    op.drop_table('statement_item', schema='glod')
    op.drop_table('person', schema='glod')
    op.drop_table('organisation_address', schema='glod')
    op.drop_table('fund', schema='glod')
    op.drop_table('subject', schema='glod')
    op.drop_table('parishioner', schema='glod')
    op.drop_table('organisation', schema='glod')
    op.drop_table('nominal_account', schema='glod')
    op.drop_table('household', schema='glod')
    op.drop_table('address', schema='glod')
    op.drop_table('account', schema='glod')
    # ### end Alembic commands ###

create tables  Revision ID: 6fb351569d30 Revises: 4<PASSWORD>1ff38b Create Date: 2019-05-06 21:59:43.998735 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###