autopep8
[sfa.git] / sfa / storage / migrations / versions / 002_authority_pis.py
1 # this move is about adding a authority x user many to many relation ship for modelling PIs
2 # that is to say users who can vouch for other users in the authority, and
3 # can create slices
4
5 from sqlalchemy import Table, MetaData, Column, ForeignKey
6 from sqlalchemy import Integer, String
7
8 metadata = MetaData()
9
10 # this is needed by migrate so it can locate 'records.record_id'
11 records = \
12     Table('records', metadata,
13           Column('record_id', Integer, primary_key=True),
14           )
15
16 # authority x user (PIs) association
17 authority_pi_table = \
18     Table('authority_pi', metadata,
19           Column('authority_id', Integer, ForeignKey(
20               'records.record_id'), primary_key=True),
21           Column('pi_id', Integer, ForeignKey(
22               'records.record_id'), primary_key=True),
23           )
24
25
26 def upgrade(migrate_engine):
27     metadata.bind = migrate_engine
28     authority_pi_table.create()
29
30
31 def downgrade(migrate_engine):
32     metadata.bind = migrate_engine
33     authority_pi_table.drop()