author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 27 May 2009 11:26:03 +0200 | |
branch | stable |
changeset 1954 | 9b20f3504af8 |
parent 1952 | 8e19c813750d |
child 1977 | 606923dff11b |
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 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
6 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 7 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8 |
""" |
|
9 |
||
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
|
10 |
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
|
11 |
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
|
12 |
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
|
13 |
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
|
14 |
% 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
|
15 |
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
|
16 |
{'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
|
17 |
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
|
18 |
|
1501
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
19 |
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
|
20 |
add_cube('card', update_database=False) |
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
21 |
|
0 | 22 |
if applcubicwebversion < (2, 47, 0) and cubicwebversion >= (2, 47, 0): |
23 |
from cubicweb.server import schemaserial |
|
24 |
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
|
25 |
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
|
26 |
add_attribute('CWRType', 'fulltext_container') |
0 | 27 |
schemaserial.HAS_FULLTEXT_CONTAINER = True |
28 |
||
29 |
||
1501
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
30 |
|
0 | 31 |
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
|
32 |
session.set_shared_data('do-not-insert-is_instance_of', True) |
0 | 33 |
add_relation_type('is_instance_of') |
34 |
# fill the relation using an efficient sql query instead of using rql |
|
35 |
sql('INSERT INTO is_instance_of_relation ' |
|
1954 | 36 |
' SELECT * from is_relation') |
0 | 37 |
checkpoint() |
1399
3f408c7a164e
unify schema sync migration commands with (hopefuly) a clearer name
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
38 |
session.set_shared_data('do-not-insert-is_instance_of', False) |
0 | 39 |
|
40 |
if applcubicwebversion < (2, 42, 0) and cubicwebversion >= (2, 42, 0): |
|
41 |
sql('ALTER TABLE entities ADD COLUMN mtime TIMESTAMP') |
|
42 |
sql('UPDATE entities SET mtime=CURRENT_TIMESTAMP') |
|
43 |
sql('CREATE INDEX entities_mtime_idx ON entities(mtime)') |
|
44 |
sql('''CREATE TABLE deleted_entities ( |
|
45 |
eid INTEGER PRIMARY KEY NOT NULL, |
|
46 |
type VARCHAR(64) NOT NULL, |
|
47 |
source VARCHAR(64) NOT NULL, |
|
48 |
dtime TIMESTAMP NOT NULL, |
|
49 |
extid VARCHAR(256) |
|
50 |
)''') |
|
51 |
sql('CREATE INDEX deleted_entities_type_idx ON deleted_entities(type)') |
|
52 |
sql('CREATE INDEX deleted_entities_dtime_idx ON deleted_entities(dtime)') |
|
53 |
sql('CREATE INDEX deleted_entities_extid_idx ON deleted_entities(extid)') |
|
54 |
checkpoint() |
|
1501
c80ca83a382f
migrate card cube in bootstrap migration
sylvain.thenault@logilab.fr
parents:
1399
diff
changeset
|
55 |