Show More
@@ -1,59 +1,52 | |||
|
1 | 1 | import logging |
|
2 | 2 | import datetime |
|
3 | 3 | |
|
4 | 4 | from sqlalchemy import * |
|
5 | 5 | from sqlalchemy.exc import DatabaseError |
|
6 | 6 | from sqlalchemy.orm import relation, backref, class_mapper |
|
7 | 7 | from sqlalchemy.orm.session import Session |
|
8 | 8 | |
|
9 | ||
|
10 | 9 | from rhodecode.lib.dbmigrate.migrate import * |
|
11 | 10 | from rhodecode.lib.dbmigrate.migrate.changeset import * |
|
12 | 11 | |
|
13 | 12 | from rhodecode.model.meta import Base |
|
14 | 13 | from rhodecode.model.db import BaseModel |
|
15 | 14 | |
|
16 | 15 | log = logging.getLogger(__name__) |
|
17 | 16 | |
|
18 | 17 | def upgrade(migrate_engine): |
|
19 | 18 | """ Upgrade operations go here. |
|
20 | 19 | Don't create your own engine; bind migrate_engine to your metadata |
|
21 | 20 | """ |
|
22 | 21 | |
|
23 | 22 | #========================================================================== |
|
24 | 23 | # Add table `groups`` |
|
25 | 24 | #========================================================================== |
|
26 | 25 | from rhodecode.model.db import Group |
|
27 | 26 | Group().__table__.create() |
|
28 | 27 | |
|
29 | 28 | #========================================================================== |
|
30 | 29 | # Add table `group_to_perm` |
|
31 | 30 | #========================================================================== |
|
32 | 31 | from rhodecode.model.db import GroupToPerm |
|
33 | 32 | GroupToPerm().__table__.create() |
|
34 | 33 | |
|
35 | 34 | #========================================================================== |
|
36 | 35 | # Upgrade of `repositories` table |
|
37 | 36 | #========================================================================== |
|
38 | tblname = 'repositories' | |
|
39 | tbl = Table(tblname, MetaData(bind=migrate_engine), autoload=True, | |
|
40 | autoload_with=migrate_engine) | |
|
37 | from rhodecode.model.db import Repository | |
|
41 | 38 | |
|
42 | 39 | #ADD group_id column# |
|
43 |
group_id = Column("group_id", Integer(), |
|
|
40 | group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), | |
|
44 | 41 | nullable=True, unique=False, default=None) |
|
45 | 42 | |
|
46 | group_id.create(tbl) | |
|
43 | group_id.create(Repository().__table__) | |
|
47 | 44 | |
|
48 | # TODO: fix this somehow ?! | |
|
49 | # cons = ForeignKeyConstraint([tbl.c.group_id], ['groups.group_id'], table=tbl) | |
|
50 | # | |
|
51 | # cons.create() | |
|
52 | 45 | return |
|
53 | 46 | |
|
54 | 47 | |
|
55 | 48 | def downgrade(migrate_engine): |
|
56 | 49 | meta = MetaData() |
|
57 | 50 | meta.bind = migrate_engine |
|
58 | 51 | |
|
59 | 52 |
General Comments 0
You need to be logged in to leave comments.
Login now