From: olivier Date: Mon, 15 Feb 2010 13:59:40 +0000 (+0000) Subject: allow dates to be null for compatibility with Django, restore location_relations... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=99b4bb8ba7f9a7a5c1bff7f13204c100473ff58d;p=telemeta-data.git allow dates to be null for compatibility with Django, restore location_relations.is_authoritative field git-svn-id: http://svn.parisson.org/svn/crem@155 3bf09e05-f825-4182-b9bc-eedd7160adf0 --- diff --git a/trunk/docref/crem.sql b/trunk/docref/crem.sql index 4ca2619..aac764f 100644 --- a/trunk/docref/crem.sql +++ b/trunk/docref/crem.sql @@ -133,7 +133,7 @@ CREATE TABLE locations ( current_location_id INTEGER, -- recursif latitude FLOAT, longitude FLOAT, - is_authoritative BOOLEAN NOT NULL DEFAULT 0, + is_authoritative BOOLEAN NOT NULL DEFAULT FALSE, INDEX(type), FOREIGN KEY(current_location_id) REFERENCES locations (id) ON DELETE SET NULL ON UPDATE CASCADE, @@ -143,7 +143,7 @@ CREATE TABLE locations ( CREATE TABLE location_aliases ( location_id INTEGER NOT NULL, alias VARCHAR(150) NOT NULL, - is_authoritative BOOLEAN NOT NULL DEFAULT 0, + is_authoritative BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY(location_id, alias), FOREIGN KEY(location_id) REFERENCES locations (id) @@ -154,6 +154,7 @@ CREATE TABLE location_relations ( location_id INTEGER NOT NULL, ancestor_location_id INTEGER NOT NULL, is_direct BOOLEAN NOT NULL DEFAULT FALSE, + is_authoritative BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY(location_id, ancestor_location_id), INDEX(is_direct), @@ -256,8 +257,11 @@ CREATE TABLE media_items ( old_code VARCHAR(250) UNIQUE NOT NULL, code VARCHAR(250) UNIQUE, -- Doit être unique mais peut être inconnu approx_duration INT NOT NULL DEFAULT 0, - recorded_from_date DATE NOT NULL DEFAULT 0, - recorded_to_date DATE NOT NULL DEFAULT 0, + -- Ces champs de date sont déclarés comme pouvant être nuls pour + -- compatibilité avec Django, car ce dernier ne prend pas en charge + -- la valeur MySQL '0000-00-00' + recorded_from_date DATE, + recorded_to_date DATE, location_id INTEGER, location_comment VARCHAR(250) NOT NULL DEFAULT '', ethnic_group_id INTEGER, diff --git a/trunk/docref/docref.odt b/trunk/docref/docref.odt index 7203e6b..a1482ea 100644 Binary files a/trunk/docref/docref.odt and b/trunk/docref/docref.odt differ diff --git a/trunk/import/migration/tasks/dates.py b/trunk/import/migration/tasks/dates.py index fd0b96a..76a3eea 100644 --- a/trunk/import/migration/tasks/dates.py +++ b/trunk/import/migration/tasks/dates.py @@ -260,7 +260,7 @@ class ItemsDateConverter(DataMigrator): 'nosuchitem' : 0 } - self.target_cursor.execute("UPDATE media_items SET recorded_from_date = 0, recorded_to_date = 0") + self.target_cursor.execute("UPDATE media_items SET recorded_from_date = NULL, recorded_to_date = NULL") self.src_cursor.execute("SELECT Cote_Phono, Annee_Enreg, Dates_Enregistr FROM Phono") diff --git a/trunk/import/migration/tasks/geoethno.py b/trunk/import/migration/tasks/geoethno.py index 4f6440a..5abc8ca 100644 --- a/trunk/import/migration/tasks/geoethno.py +++ b/trunk/import/migration/tasks/geoethno.py @@ -113,9 +113,9 @@ class GeoEthnoImporter(DataMigrator): parent_id = self.getone("SELECT id FROM locations WHERE name = %s", (parentName,)) if id != parent_id: self.stats['relations'] += self.replace("INSERT INTO location_relations "+ - "(location_id, ancestor_location_id, is_direct) "+ - "VALUE (%s, %s, %s)", - (id, parent_id, 1)) + "(location_id, ancestor_location_id, is_direct, is_authoritative) "+ + "VALUE (%s, %s, %s, %s)", + (id, parent_id, 1, 1)) for hname in historic_names: self.stats['historical names'] += self.replace("INSERT INTO locations "+