misc/migration/bootstrapmigration_repository.py
author Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 18 Feb 2009 15:41:10 +0100
branchtls-sprint
changeset 798 0015b33a7336
parent 0 b97547f5f1fa
child 1398 5fe84a5f7035
permissions -rw-r--r--
fix State's RichString definition: 'default' was used instead of 'default_format'

"""allways executed before all others in server migration

it should only include low level schema changes

:organization: Logilab
:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""

if applcubicwebversion < (2, 47, 0) and cubicwebversion >= (2, 47, 0):
    from cubicweb.server import schemaserial
    schemaserial.HAS_FULLTEXT_CONTAINER = False
    cnx.set_shared_data('do-not-insert-is_instance_of', True)
    add_attribute('ERType', 'fulltext_container')
    schemaserial.HAS_FULLTEXT_CONTAINER = True


 
if applcubicwebversion < (2, 50, 0) and cubicwebversion >= (2, 50, 0):
    cnx.set_shared_data('do-not-insert-is_instance_of', True)
    add_relation_type('is_instance_of')
    # fill the relation using an efficient sql query instead of using rql
    sql('INSERT INTO is_instance_of_relation '
	'  SELECT * from is_relation')
    checkpoint()
    cnx.set_shared_data('do-not-insert-is_instance_of', False)

if applcubicwebversion < (2, 42, 0) and cubicwebversion >= (2, 42, 0):
    sql('ALTER TABLE entities ADD COLUMN mtime TIMESTAMP')
    sql('UPDATE entities SET mtime=CURRENT_TIMESTAMP')
    sql('CREATE INDEX entities_mtime_idx ON entities(mtime)')
    sql('''CREATE TABLE deleted_entities (
  eid INTEGER PRIMARY KEY NOT NULL,
  type VARCHAR(64) NOT NULL,
  source VARCHAR(64) NOT NULL,
  dtime TIMESTAMP NOT NULL,
  extid VARCHAR(256)
)''')
    sql('CREATE INDEX deleted_entities_type_idx ON deleted_entities(type)')
    sql('CREATE INDEX deleted_entities_dtime_idx ON deleted_entities(dtime)')
    sql('CREATE INDEX deleted_entities_extid_idx ON deleted_entities(extid)')
    checkpoint()