Mercurial > kallithea
annotate rhodecode/lib/dbmigrate/versions/006_version_1_4_0.py @ 4099:43b54436d459
update issue tracker and official site
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 01 Sep 2013 19:56:08 +0200 |
parents | fa6ba6727475 |
children | 7e5f8c12a3fc |
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 |
3148
b31984972e95
Migration upgrades cache for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2815
diff
changeset
|
15 from rhodecode.lib.dbmigrate.versions import _reset_base |
2549
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 log = logging.getLogger(__name__) |
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 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 def upgrade(migrate_engine): |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
21 """ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
22 Upgrade operations go here. |
2549
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 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
|
24 """ |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
26 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
27 # USEREMAILMAP |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
28 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
29 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
|
30 tbl = UserEmailMap.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
31 tbl.create() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
32 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
33 # PULL REQUEST |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
34 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
35 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
|
36 tbl = PullRequest.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
37 tbl.create() |
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 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
40 # PULL REQUEST REVIEWERS |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
41 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
42 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
|
43 tbl = PullRequestReviewers.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
44 tbl.create() |
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 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
47 # CHANGESET STATUS |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
48 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
49 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
|
50 tbl = ChangesetStatus.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
51 tbl.create() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
52 |
3148
b31984972e95
Migration upgrades cache for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2815
diff
changeset
|
53 _reset_base(migrate_engine) |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
54 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
55 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
56 # USERS TABLE |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
57 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
58 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
|
59 tbl = User.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
60 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
61 # change column name -> firstname |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
62 col = User.__table__.columns.name |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
63 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
|
64 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
|
65 col.alter(name="firstname", table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
66 |
2769 | 67 # add inherit_default_permission column |
2767
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
68 inherit_default_permissions = Column("inherit_default_permissions", |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
69 Boolean(), nullable=True, unique=None, |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
70 default=True) |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
71 inherit_default_permissions.create(table=tbl) |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
72 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
|
73 |
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
74 #========================================================================== |
2769 | 75 # USERS GROUP TABLE |
76 #========================================================================== | |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3148
diff
changeset
|
77 from rhodecode.lib.dbmigrate.schema.db_1_3_0 import UserGroup |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3148
diff
changeset
|
78 tbl = UserGroup.__table__ |
2769 | 79 # add inherit_default_permission column |
80 gr_inherit_default_permissions = Column( | |
81 "users_group_inherit_default_permissions", | |
82 Boolean(), nullable=True, unique=None, | |
83 default=True) | |
84 gr_inherit_default_permissions.create(table=tbl) | |
85 gr_inherit_default_permissions.alter(nullable=False, default=True, table=tbl) | |
86 | |
87 #========================================================================== | |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
88 # REPOSITORIES |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
89 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
90 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
|
91 tbl = Repository.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
92 |
2769 | 93 # add enable locking column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
94 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
|
95 unique=None, default=False) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
96 enable_locking.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
97 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
|
98 |
2769 | 99 # add locked column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
100 _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
|
101 default=None) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
102 _locked.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
103 |
2769 | 104 #add langing revision column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
105 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
|
106 unique=False, default='tip') |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
107 landing_rev.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
108 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
|
109 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
110 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
111 # GROUPS |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
112 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
113 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
|
114 tbl = RepoGroup.__table__ |
2769 | 115 |
116 # add enable locking column | |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
117 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
|
118 unique=None, default=False) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
119 enable_locking.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
120 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
|
121 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
122 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
123 # CACHE INVALIDATION |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
124 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
125 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
|
126 tbl = CacheInvalidation.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
127 |
2769 | 128 # add INDEX for cache keys |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
129 col = CacheInvalidation.__table__.columns.cache_key |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
130 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
|
131 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
132 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
133 # NOTIFICATION |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
134 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
135 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
|
136 tbl = Notification.__table__ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
137 |
2769 | 138 # add index for notification type |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
139 col = Notification.__table__.columns.type |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
140 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
|
141 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
142 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
143 # CHANGESET_COMMENTS |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
144 #========================================================================== |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
145 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
|
146 |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
147 tbl = ChangesetComment.__table__ |
2769 | 148 col = ChangesetComment.__table__.columns.revision |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
149 |
2769 | 150 # add index for revisions |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
151 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
|
152 |
2769 | 153 # add hl_lines column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
154 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
|
155 hl_lines.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
156 |
2769 | 157 # add created_on column |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
158 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
|
159 default=datetime.datetime.now) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
160 created_on.create(table=tbl) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
161 created_on.alter(nullable=False, default=datetime.datetime.now) |
2769 | 162 |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
163 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
|
164 default=datetime.datetime.now) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
165 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
|
166 |
2769 | 167 # add FK to pull_request |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
168 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
|
169 ForeignKey('pull_requests.pull_request_id'), |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
170 nullable=True) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2550
diff
changeset
|
171 pull_request_id.create(table=tbl) |
3148
b31984972e95
Migration upgrades cache for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2815
diff
changeset
|
172 _reset_base(migrate_engine) |
2549
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
173 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
174 |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
175 def downgrade(migrate_engine): |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
176 meta = MetaData() |
411cd8fba253
added dummy revision 6 for db upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
177 meta.bind = migrate_engine |