e19a6bcd0521b696e879c6582167dc09a784bcf2
[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 can create slices
3
4 from sqlalchemy import Table, MetaData, Column, ForeignKey
5 from sqlalchemy import Integer, String
6
7 metadata = MetaData()
8
9 # this is needed by migrate so it can locate 'records.record_id'
10 records = \
11     Table ( 'records', metadata,
12             Column ('record_id', Integer, primary_key=True),
13             )
14
15 # authority x user (PIs) association
16 authority_pi_table = \
17     Table ( 'authority_pi', metadata,
18             Column ('authority_id', Integer, ForeignKey ('records.record_id'), primary_key=True),
19             Column ('pi_id', Integer, ForeignKey ('records.record_id'), primary_key=True),
20             )
21
22 def upgrade(migrate_engine):
23     metadata.bind = migrate_engine
24     authority_pi_table.create()
25
26 def downgrade(migrate_engine):
27     metadata.bind = migrate_engine
28     authority_pi_table.drop()