author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Thu, 23 Jul 2009 15:28:41 +0200 | |
changeset 2456 | aa25d6b244c8 |
parent 2275 | bc0bed0616a3 |
child 2462 | 9e670072884d |
permissions | -rw-r--r-- |
0 | 1 |
"""allways executed before all others in server migration |
2 |
||
3 |
it should only include low level schema changes |
|
4 |
||
5 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1954
diff
changeset
|
6 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 7 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1954
diff
changeset
|
8 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 9 |
""" |
10 |
||
2275
bc0bed0616a3
fix #344387, remember upgraded version step by step
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
11 |
applcubicwebversion, cubicwebversion = versions_map['cubicweb'] |
bc0bed0616a3
fix #344387, remember upgraded version step by step
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
12 |
|
1952
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
13 |
if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1): |
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
14 |
from base64 import b64encode |
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
15 |
for table in ('entities', 'deleted_entities'): |
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
16 |
for eid, extid in sql('SELECT eid, extid FROM %s WHERE extid is NOT NULL' |
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
17 |
% table, ask_confirm=False): |
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
18 |
sql('UPDATE %s SET extid=%%(extid)s WHERE eid=%%(eid)s' % table, |
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
19 |
{'extid': b64encode(extid), 'eid': eid}, ask_confirm=False) |
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
20 |
checkpoint() |
8e19c813750d
fix extid handling: ensure encoded string is given, and store them as base64 (see note in native.py).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1501
diff
changeset
|
21 |
|
1501
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
22 |
if applcubicwebversion < (3, 2, 0) and cubicwebversion >= (3, 2, 0): |
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
23 |
add_cube('card', update_database=False) |
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
24 |
|
0 | 25 |
if applcubicwebversion < (2, 47, 0) and cubicwebversion >= (2, 47, 0): |
26 |
from cubicweb.server import schemaserial |
|
27 |
schemaserial.HAS_FULLTEXT_CONTAINER = False |
|
1399
3f408c7a164e
unify schema sync migration commands with (hopefuly) a clearer name
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
28 |
session.set_shared_data('do-not-insert-is_instance_of', True) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
29 |
add_attribute('CWRType', 'fulltext_container') |
0 | 30 |
schemaserial.HAS_FULLTEXT_CONTAINER = True |
31 |
||
32 |
||
1501
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
33 |
|
0 | 34 |
if applcubicwebversion < (2, 50, 0) and cubicwebversion >= (2, 50, 0): |
1399
3f408c7a164e
unify schema sync migration commands with (hopefuly) a clearer name
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
35 |
session.set_shared_data('do-not-insert-is_instance_of', True) |
0 | 36 |
add_relation_type('is_instance_of') |
37 |
# fill the relation using an efficient sql query instead of using rql |
|
38 |
sql('INSERT INTO is_instance_of_relation ' |
|
1954 | 39 |
' SELECT * from is_relation') |
0 | 40 |
checkpoint() |
1399
3f408c7a164e
unify schema sync migration commands with (hopefuly) a clearer name
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
41 |
session.set_shared_data('do-not-insert-is_instance_of', False) |
0 | 42 |
|
43 |
if applcubicwebversion < (2, 42, 0) and cubicwebversion >= (2, 42, 0): |
|
44 |
sql('ALTER TABLE entities ADD COLUMN mtime TIMESTAMP') |
|
45 |
sql('UPDATE entities SET mtime=CURRENT_TIMESTAMP') |
|
46 |
sql('CREATE INDEX entities_mtime_idx ON entities(mtime)') |
|
47 |
sql('''CREATE TABLE deleted_entities ( |
|
48 |
eid INTEGER PRIMARY KEY NOT NULL, |
|
49 |
type VARCHAR(64) NOT NULL, |
|
50 |
source VARCHAR(64) NOT NULL, |
|
51 |
dtime TIMESTAMP NOT NULL, |
|
52 |
extid VARCHAR(256) |
|
53 |
)''') |
|
54 |
sql('CREATE INDEX deleted_entities_type_idx ON deleted_entities(type)') |
|
55 |
sql('CREATE INDEX deleted_entities_dtime_idx ON deleted_entities(dtime)') |
|
56 |
sql('CREATE INDEX deleted_entities_extid_idx ON deleted_entities(extid)') |
|
57 |
checkpoint() |
|
1501
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
58 |