Mercurial > kallithea
annotate rhodecode/lib/dbmigrate/versions/006_version_1_4_0.py @ 3129:23ec6e88b234 beta
Merged translation from pullrequest #92
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 02 Jan 2013 00:32:36 +0100 |
parents | acc05c33cc0c |
children | b31984972e95 |
rev | line source |
---|---|
2549
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 import logging |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 import datetime |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 from sqlalchemy import * |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 from sqlalchemy.exc import DatabaseError |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 from sqlalchemy.orm import relation, backref, class_mapper |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 from sqlalchemy.orm.session import Session |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
8 from sqlalchemy.ext.declarative import declarative_base |
2549
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 from rhodecode.lib.dbmigrate.migrate import * |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 from rhodecode.lib.dbmigrate.migrate.changeset import * |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 from rhodecode.model.meta import Base |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
14 from rhodecode.model import meta |
2549
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 log = logging.getLogger(__name__) |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 def upgrade(migrate_engine): |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
20 """ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
21 Upgrade operations go here. |
2549
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 Don't create your own engine; bind migrate_engine to your metadata |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 """ |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
25 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
26 # USEREMAILMAP |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
27 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
28 from rhodecode.lib.dbmigrate.schema.db_1_4_0 import UserEmailMap |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
29 tbl = UserEmailMap.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
30 tbl.create() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
31 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
32 # PULL REQUEST |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
33 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
34 from rhodecode.lib.dbmigrate.schema.db_1_4_0 import PullRequest |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
35 tbl = PullRequest.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
36 tbl.create() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
37 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
38 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
39 # PULL REQUEST REVIEWERS |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
40 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
41 from rhodecode.lib.dbmigrate.schema.db_1_4_0 import PullRequestReviewers |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
42 tbl = PullRequestReviewers.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
43 tbl.create() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
44 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
45 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
46 # CHANGESET STATUS |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
47 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
48 from rhodecode.lib.dbmigrate.schema.db_1_4_0 import ChangesetStatus |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
49 tbl = ChangesetStatus.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
50 tbl.create() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
51 |
2815
acc05c33cc0c
White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2769
diff
changeset
|
52 ## RESET COMPLETLY THE metadata for sqlalchemy to use the 1_3_0 Base |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
53 Base = declarative_base() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
54 Base.metadata.clear() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
55 Base.metadata = MetaData() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
56 Base.metadata.bind = migrate_engine |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
57 meta.Base = Base |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
58 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
59 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
60 # USERS TABLE |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
61 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
62 from rhodecode.lib.dbmigrate.schema.db_1_3_0 import User |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
63 tbl = User.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
64 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
65 # change column name -> firstname |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
66 col = User.__table__.columns.name |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
67 col.alter(index=Index('u_username_idx', 'username')) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
68 col.alter(index=Index('u_email_idx', 'email')) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
69 col.alter(name="firstname", table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
70 |
2769 | 71 # add inherit_default_permission column |
2767
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
72 inherit_default_permissions = Column("inherit_default_permissions", |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
73 Boolean(), nullable=True, unique=None, |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
74 default=True) |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
75 inherit_default_permissions.create(table=tbl) |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
76 inherit_default_permissions.alter(nullable=False, default=True, table=tbl) |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
77 |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
78 #========================================================================== |
2769 | 79 # USERS GROUP TABLE |
80 #========================================================================== | |
81 from rhodecode.lib.dbmigrate.schema.db_1_3_0 import UsersGroup | |
82 tbl = UsersGroup.__table__ | |
83 # add inherit_default_permission column | |
84 gr_inherit_default_permissions = Column( | |
85 "users_group_inherit_default_permissions", | |
86 Boolean(), nullable=True, unique=None, | |
87 default=True) | |
88 gr_inherit_default_permissions.create(table=tbl) | |
89 gr_inherit_default_permissions.alter(nullable=False, default=True, table=tbl) | |
90 | |
91 #========================================================================== | |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
92 # REPOSITORIES |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
93 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
94 from rhodecode.lib.dbmigrate.schema.db_1_3_0 import Repository |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
95 tbl = Repository.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
96 |
2769 | 97 # add enable locking column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
98 enable_locking = Column("enable_locking", Boolean(), nullable=True, |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
99 unique=None, default=False) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
100 enable_locking.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
101 enable_locking.alter(nullable=False, default=False, table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
102 |
2769 | 103 # add locked column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
104 _locked = Column("locked", String(255), nullable=True, unique=False, |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
105 default=None) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
106 _locked.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
107 |
2769 | 108 #add langing revision column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
109 landing_rev = Column("landing_revision", String(255), nullable=True, |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
110 unique=False, default='tip') |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
111 landing_rev.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
112 landing_rev.alter(nullable=False, default='tip', table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
113 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
114 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
115 # GROUPS |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
116 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
117 from rhodecode.lib.dbmigrate.schema.db_1_3_0 import RepoGroup |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
118 tbl = RepoGroup.__table__ |
2769 | 119 |
120 # add enable locking column | |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
121 enable_locking = Column("enable_locking", Boolean(), nullable=True, |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
122 unique=None, default=False) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
123 enable_locking.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
124 enable_locking.alter(nullable=False, default=False) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
125 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
126 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
127 # CACHE INVALIDATION |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
128 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
129 from rhodecode.lib.dbmigrate.schema.db_1_3_0 import CacheInvalidation |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
130 tbl = CacheInvalidation.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
131 |
2769 | 132 # add INDEX for cache keys |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
133 col = CacheInvalidation.__table__.columns.cache_key |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
134 col.alter(index=Index('key_idx', 'cache_key')) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
135 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
136 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
137 # NOTIFICATION |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
138 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
139 from rhodecode.lib.dbmigrate.schema.db_1_3_0 import Notification |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
140 tbl = Notification.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
141 |
2769 | 142 # add index for notification type |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
143 col = Notification.__table__.columns.type |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
144 col.alter(index=Index('notification_type_idx', 'type'),) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
145 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
146 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
147 # CHANGESET_COMMENTS |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
148 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
149 from rhodecode.lib.dbmigrate.schema.db_1_3_0 import ChangesetComment |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
150 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
151 tbl = ChangesetComment.__table__ |
2769 | 152 col = ChangesetComment.__table__.columns.revision |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
153 |
2769 | 154 # add index for revisions |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
155 col.alter(index=Index('cc_revision_idx', 'revision'),) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
156 |
2769 | 157 # add hl_lines column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
158 hl_lines = Column('hl_lines', Unicode(512), nullable=True) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
159 hl_lines.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
160 |
2769 | 161 # add created_on column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
162 created_on = Column('created_on', DateTime(timezone=False), nullable=True, |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
163 default=datetime.datetime.now) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
164 created_on.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
165 created_on.alter(nullable=False, default=datetime.datetime.now) |
2769 | 166 |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
167 modified_at = Column('modified_at', DateTime(timezone=False), nullable=False, |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
168 default=datetime.datetime.now) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
169 modified_at.alter(type=DateTime(timezone=False), table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
170 |
2769 | 171 # add FK to pull_request |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
172 pull_request_id = Column("pull_request_id", Integer(), |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
173 ForeignKey('pull_requests.pull_request_id'), |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
174 nullable=True) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
175 pull_request_id.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
176 ## RESET COMPLETLY THE metadata for sqlalchemy back after using 1_3_0 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
177 Base = declarative_base() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
178 Base.metadata.clear() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
179 Base.metadata = MetaData() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
180 Base.metadata.bind = migrate_engine |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
181 meta.Base = Base |
2549
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
182 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
183 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
184 def downgrade(migrate_engine): |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
185 meta = MetaData() |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
186 meta.bind = migrate_engine |