Mercurial > kallithea
annotate rhodecode/lib/dbmigrate/versions/007_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 | c9baaacb670a |
children | 7e5f8c12a3fc |
rev | line source |
---|---|
2797
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 import logging |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 import datetime |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 from sqlalchemy import * |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 from sqlalchemy.exc import DatabaseError |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 from sqlalchemy.orm import relation, backref, class_mapper |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 from sqlalchemy.orm.session import Session |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 from sqlalchemy.ext.declarative import declarative_base |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 from rhodecode.lib.dbmigrate.migrate import * |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 from rhodecode.lib.dbmigrate.migrate.changeset import * |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 from rhodecode.model.meta import Base |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 from rhodecode.model import meta |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 log = logging.getLogger(__name__) |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 def upgrade(migrate_engine): |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 """ |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 Upgrade operations go here. |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 Don't create your own engine; bind migrate_engine to your metadata |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 """ |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 #========================================================================== |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 # CHANGESET_COMMENTS |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 #========================================================================== |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 from rhodecode.lib.dbmigrate.schema.db_1_4_0 import ChangesetComment |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 tbl_name = ChangesetComment.__tablename__ |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 tbl = Table(tbl_name, |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 MetaData(bind=migrate_engine), autoload=True, |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 autoload_with=migrate_engine) |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 col = tbl.columns.revision |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 # remove nullability from revision field |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 col.alter(nullable=True) |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 #========================================================================== |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 # REPOSITORY |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 #========================================================================== |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 from rhodecode.lib.dbmigrate.schema.db_1_4_0 import Repository |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 tbl = Repository.__table__ |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 updated_on = Column('updated_on', DateTime(timezone=False), |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 nullable=True, unique=None) |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 # create created on column for future lightweight main page |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 updated_on.create(table=tbl) |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 def downgrade(migrate_engine): |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 meta = MetaData() |
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 meta.bind = migrate_engine |