annotate rhodecode/lib/dbmigrate/versions/003_version_1_2_0.py @ 1260:83da8834f7b1 beta

removed bad import
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 15 Apr 2011 01:00:29 +0200
parents 6832ef664673
children aa7e45ad0cea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 import logging
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 import datetime
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 from sqlalchemy import *
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 from sqlalchemy.exc import DatabaseError
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 from sqlalchemy.orm import relation, backref, class_mapper
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 from sqlalchemy.orm.session import Session
907
2f83756f3041 Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents: 900
diff changeset
8
2f83756f3041 Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents: 900
diff changeset
9 from rhodecode.lib.dbmigrate.migrate import *
2f83756f3041 Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents: 900
diff changeset
10 from rhodecode.lib.dbmigrate.migrate.changeset import *
2f83756f3041 Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents: 900
diff changeset
11
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 from rhodecode.model.meta import Base
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 log = logging.getLogger(__name__)
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 def upgrade(migrate_engine):
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1133
diff changeset
17 """ Upgrade operations go here.
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 Don't create your own engine; bind migrate_engine to your metadata
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 """
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 #==========================================================================
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 # Add table `groups``
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 #==========================================================================
1026
3c80eb712a78 uncommented migrate tables, docfix
Marcin Kuzminski <marcin@python-works.com>
parents: 1023
diff changeset
24 from rhodecode.model.db import Group
3c80eb712a78 uncommented migrate tables, docfix
Marcin Kuzminski <marcin@python-works.com>
parents: 1023
diff changeset
25 Group().__table__.create()
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 #==========================================================================
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 # Add table `group_to_perm`
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 #==========================================================================
1026
3c80eb712a78 uncommented migrate tables, docfix
Marcin Kuzminski <marcin@python-works.com>
parents: 1023
diff changeset
30 from rhodecode.model.db import GroupToPerm
3c80eb712a78 uncommented migrate tables, docfix
Marcin Kuzminski <marcin@python-works.com>
parents: 1023
diff changeset
31 GroupToPerm().__table__.create()
1023
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
32
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
33 #==========================================================================
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
34 # Add table `users_groups`
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
35 #==========================================================================
1026
3c80eb712a78 uncommented migrate tables, docfix
Marcin Kuzminski <marcin@python-works.com>
parents: 1023
diff changeset
36 from rhodecode.model.db import UsersGroup
3c80eb712a78 uncommented migrate tables, docfix
Marcin Kuzminski <marcin@python-works.com>
parents: 1023
diff changeset
37 UsersGroup().__table__.create()
1023
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
38
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
39 #==========================================================================
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
40 # Add table `users_groups_members`
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
41 #==========================================================================
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
42 from rhodecode.model.db import UsersGroupMember
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
43 UsersGroupMember().__table__.create()
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
44
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
45 #==========================================================================
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
46 # Add table `users_group_to_perm`
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
47 #==========================================================================
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
48 from rhodecode.model.db import UsersGroupToPerm
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
49 UsersGroupToPerm().__table__.create()
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
50
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
51
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
52 #==========================================================================
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
53 # Upgrade of `users` table
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
54 #==========================================================================
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
55 from rhodecode.model.db import User
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
56
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
57 #add column
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
58 ldap_dn = Column("ldap_dn", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
59 ldap_dn.create(User().__table__)
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
60
1133
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
61 api_key = Column("api_key", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
62 api_key.create(User().__table__)
1023
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
63
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
64 #remove old column
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
65 is_ldap = Column("is_ldap", Boolean(), nullable=False, unique=None, default=False)
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
66 is_ldap.drop(User().__table__)
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
67
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 #==========================================================================
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 # Upgrade of `repositories` table
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1133
diff changeset
71 #==========================================================================
908
de560c47dd03 Added missing FK to migration
Marcin Kuzminski <marcin@python-works.com>
parents: 907
diff changeset
72 from rhodecode.model.db import Repository
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73
1023
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
74 #ADD downloads column#
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
75 enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
76 enable_downloads.create(Repository().__table__)
e7478ac19f9f updated db migrations to schema 3
Marcin Kuzminski <marcin@python-works.com>
parents: 908
diff changeset
77
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 #ADD group_id column#
908
de560c47dd03 Added missing FK to migration
Marcin Kuzminski <marcin@python-works.com>
parents: 907
diff changeset
79 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'),
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 nullable=True, unique=False, default=None)
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81
908
de560c47dd03 Added missing FK to migration
Marcin Kuzminski <marcin@python-works.com>
parents: 907
diff changeset
82 group_id.create(Repository().__table__)
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83
1133
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
84
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
85 #ADD clone_uri column#
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
86
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
87 clone_uri = Column("clone_uri", String(length=255, convert_unicode=False,
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
88 assert_unicode=None),
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
89 nullable=True, unique=False, default=None)
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
90
07fcf1683503 updated migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 1026
diff changeset
91 clone_uri.create(Repository().__table__)
900
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 return
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 def downgrade(migrate_engine):
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 meta = MetaData()
07f248329a3b updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 meta.bind = migrate_engine