]> git.parisson.com Git - telemeta-data.git/commitdiff
allow dates to be null for compatibility with Django, restore location_relations...
authorolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Mon, 15 Feb 2010 13:59:40 +0000 (13:59 +0000)
committerolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Mon, 15 Feb 2010 13:59:40 +0000 (13:59 +0000)
git-svn-id: http://svn.parisson.org/svn/crem@155 3bf09e05-f825-4182-b9bc-eedd7160adf0

trunk/docref/crem.sql
trunk/docref/docref.odt
trunk/import/migration/tasks/dates.py
trunk/import/migration/tasks/geoethno.py

index 4ca26194e1874e6795f5c0d4a1c10fb90fcd1865..aac764f5671e1281a5d7ae52c3db72a38faad8e9 100644 (file)
@@ -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,
index 7203e6b8f216a97d699f8e9f9caf59ea8ec8f493..a1482ead57d929ffa0c0376aed42034ad381152d 100644 (file)
Binary files a/trunk/docref/docref.odt and b/trunk/docref/docref.odt differ
index fd0b96afba6231318865a3eb92ac67905988445d..76a3eea8a0989962619177876fea970fa95d0aa4 100644 (file)
@@ -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")
 
index 4f6440a617b6ece11e5974670a16faaf2d429a3b..5abc8ca5c33939fa92947f61e2f551f3cf1ece9e 100644 (file)
@@ -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 "+