Migrate from Camelot 11.12.30 to 12.06.29ΒΆ

The place of the default metadata has changed. So the top line at the model files should change from:

from camelot.model import metadata

to:

from camelot.core.sql import metadata

All Camelot models that you wish to use should be explicitely imported in the setup_model method in settings.py. And the metadata should be bound to the engine explicitly in the setup_model method:

def setup_model():
    from camelot.core.sql import metadata
    metadata.bind = ENGINE()
    from camelot.model import authentication
    from camelot.model import party
    from camelot.model import i18n
    from camelot.model import memento
    from camelot.model import fixture
    setup_model( True )

The authentication module has been split into authentication and party. Person and Organization related imports should be redefined

from camelot.model.authentication import Person

Should become

from camelot.model.party import Person

There were some changes in the data model of Camelot, in the parts that track change history and handle authentication. Run this SQL script against your database to do the upgrade, after taking a backup.

On Postgresql

ALTER TABLE memento ADD memento_type INT;
ALTER TABLE memento ADD COLUMN previous_attributes bytea;
UPDATE memento SET
    memento_type = 1,
    previous_attributes = memento_update.previous_attributes
FROM memento_update WHERE memento.id = memento_update.memento_id;
UPDATE memento SET
    memento_type = 2,
    previous_attributes = memento_delete.previous_attributes
FROM memento_delete WHERE memento.id = memento_delete.memento_id;
UPDATE memento SET
    memento_type = 3
FROM memento_create WHERE memento.id = memento_create.memento_id;
ALTER TABLE memento ALTER COLUMN memento_type SET NOT NULL;
ALTER TABLE memento DROP COLUMN row_type;
DROP TABLE memento_update;
DROP TABLE memento_delete;
DROP TABLE memento_create;
CREATE INDEX ix_memento_memento_type
    ON memento (memento_type);
ALTER TABLE authentication_mechanism ADD COLUMN authentication_type INT;
ALTER TABLE authentication_mechanism ADD COLUMN username VARCHAR(40);
ALTER TABLE authentication_mechanism ADD COLUMN password VARCHAR(200);
ALTER TABLE authentication_mechanism ADD COLUMN from_date DATE;
ALTER TABLE authentication_mechanism ADD COLUMN thru_date DATE;
ALTER TABLE authentication_mechanism DROP COLUMN row_type;
ALTER TABLE authentication_mechanism DROP COLUMN is_active;
UPDATE authentication_mechanism SET
    authentication_type = 1,
    from_date = '2000-01-01',
    thru_date = '2400-12-31',
    username = authentication_mechanism_username.username,
    password = authentication_mechanism_username.password
FROM authentication_mechanism_username WHERE authentication_mechanism.id = authentication_mechanism_username.authenticationmechanism_id;
ALTER TABLE authentication_mechanism ALTER COLUMN authentication_type SET NOT NULL;
ALTER TABLE authentication_mechanism ALTER COLUMN from_date SET NOT NULL;
ALTER TABLE authentication_mechanism ALTER COLUMN thru_date SET NOT NULL;
DROP TABLE authentication_mechanism_username;
CREATE INDEX ix_authentication_mechanism_from_date
    ON authentication_mechanism (from_date);
CREATE INDEX ix_authentication_mechanism_thru_date
    ON authentication_mechanism (thru_date);
CREATE INDEX ix_authentication_mechanism_username
    ON authentication_mechanism (username);
CREATE INDEX ix_authentication_mechanism_authentication_type
    ON authentication_mechanism (authentication_type);

On MySQL

ALTER TABLE memento ADD memento_type INT;
ALTER TABLE memento ADD COLUMN previous_attributes blob;
UPDATE memento, memento_update SET
    memento.memento_type = 1,
    memento.previous_attributes = memento_update.previous_attributes
WHERE memento.id = memento_update.memento_id;
UPDATE memento, memento_delete SET
    memento.memento_type = 2,
    memento.previous_attributes = memento_delete.previous_attributes
WHERE memento.id = memento_delete.memento_id;
UPDATE memento, memento_create SET
    memento.memento_type = 3
WHERE memento.id = memento_create.memento_id;
ALTER TABLE memento ALTER COLUMN memento_type SET NOT NULL;
ALTER TABLE memento DROP COLUMN row_type;
DROP TABLE memento_update;
DROP TABLE memento_delete;
DROP TABLE memento_create;
CREATE INDEX ix_memento_memento_type
    ON memento (memento_type);
ALTER TABLE authentication_mechanism ADD COLUMN authentication_type INT;
ALTER TABLE authentication_mechanism ADD COLUMN username VARCHAR(40);
ALTER TABLE authentication_mechanism ADD COLUMN password VARCHAR(200);
ALTER TABLE authentication_mechanism ADD COLUMN from_date DATE;
ALTER TABLE authentication_mechanism ADD COLUMN thru_date DATE;
ALTER TABLE authentication_mechanism DROP COLUMN row_type;
ALTER TABLE authentication_mechanism DROP COLUMN is_active;
UPDATE authentication_mechanism, authentication_mechanism_username SET
    authentication_mechanism.authentication_type = 1,
    authentication_mechanism.from_date = '2000-01-01',
    authentication_mechanism.thru_date = '2400-12-31',
    authentication_mechanism.username = authentication_mechanism_username.username,
    authentication_mechanism.password = authentication_mechanism_username.password
WHERE authentication_mechanism.id = authentication_mechanism_username.authenticationmechanism_id;
ALTER TABLE authentication_mechanism ALTER COLUMN authentication_type SET NOT NULL;
ALTER TABLE authentication_mechanism ALTER COLUMN from_date SET NOT NULL;
ALTER TABLE authentication_mechanism ALTER COLUMN thru_date SET NOT NULL;
DROP TABLE authentication_mechanism_username;
CREATE INDEX ix_authentication_mechanism_from_date
    ON authentication_mechanism (from_date);
CREATE INDEX ix_authentication_mechanism_thru_date
    ON authentication_mechanism (thru_date);
CREATE INDEX ix_authentication_mechanism_username
    ON authentication_mechanism (username);
CREATE INDEX ix_authentication_mechanism_authentication_type
    ON authentication_mechanism (authentication_type);

Or simply drop these tables and have them recreated by Camelot and lose the history information

DROP TABLE memento_update;
DROP TABLE memento_delete;
DROP TABLE memento_create;
DROP TABLE memento;
DROP TABLE authentication_mechanism_username;
DROP TABLE authentication_mechanism;

Consider converting your settings.py module to a settings object .

Previous topic

Migrate existing Camelot projects

Next topic

Migrate from Camelot 12.06.29 to 13.04.13

This Page