From: olivier Date: Thu, 11 Feb 2010 13:02:34 +0000 (+0000) Subject: storage durations as integers for compatibility with Django mysql backend X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=3c56c9702cacabbfff38119fb8dc1d6552d5970b;p=telemeta-data.git storage durations as integers for compatibility with Django mysql backend git-svn-id: http://svn.parisson.org/svn/crem@153 3bf09e05-f825-4182-b9bc-eedd7160adf0 --- diff --git a/trunk/docref/crem.sql b/trunk/docref/crem.sql index 705d30b..4ca2619 100644 --- a/trunk/docref/crem.sql +++ b/trunk/docref/crem.sql @@ -213,7 +213,7 @@ CREATE TABLE media_collections ( recorded_from_year INTEGER NOT NULL DEFAULT 0, recorded_to_year INTEGER NOT NULL DEFAULT 0, recording_context_id INTEGER, - approx_duration TIME NOT NULL DEFAULT 0, + approx_duration INT NOT NULL DEFAULT 0, doctype_code INTEGER NOT NULL DEFAULT 0, travail VARCHAR(250) NOT NULL DEFAULT '', state TEXT NOT NULL DEFAULT '', @@ -255,7 +255,7 @@ CREATE TABLE media_items ( track VARCHAR(250) NOT NULL DEFAULT '', old_code VARCHAR(250) UNIQUE NOT NULL, code VARCHAR(250) UNIQUE, -- Doit être unique mais peut être inconnu - approx_duration TIME NOT NULL DEFAULT 0, + approx_duration INT NOT NULL DEFAULT 0, recorded_from_date DATE NOT NULL DEFAULT 0, recorded_to_date DATE NOT NULL DEFAULT 0, location_id INTEGER, diff --git a/trunk/docref/docref.odt b/trunk/docref/docref.odt index 12a0173..7203e6b 100644 Binary files a/trunk/docref/docref.odt and b/trunk/docref/docref.odt differ diff --git a/trunk/import/migration/migrate.py b/trunk/import/migration/migrate.py old mode 100644 new mode 100755 index 5e13694..7697d12 --- a/trunk/import/migration/migrate.py +++ b/trunk/import/migration/migrate.py @@ -1,3 +1,4 @@ +#!/usr/bin/python # -*- coding: utf-8 -*- # # CREM Database migrator diff --git a/trunk/import/migration/tasks/collections.py b/trunk/import/migration/tasks/collections.py index c847464..7c176a8 100644 --- a/trunk/import/migration/tasks/collections.py +++ b/trunk/import/migration/tasks/collections.py @@ -58,7 +58,7 @@ class CollectionsCopyMigrator(DataMigrator): ('Ref_Biblio', 'external_references'), ('Commentaire', 'comment'), ('Autres_Cotes', 'alt_ids'), - ('Duree_approx', 'approx_duration'), + ('Duree_approx', 'approx_duration', 'TIME_TO_SEC'), ('Tri DiBm', 'doctype_code'), ('Travail', 'travail'), ('CompilFacePlage', 'state'), diff --git a/trunk/import/migration/tasks/core.py b/trunk/import/migration/tasks/core.py index b138d2a..c9acafa 100644 --- a/trunk/import/migration/tasks/core.py +++ b/trunk/import/migration/tasks/core.py @@ -87,9 +87,12 @@ class DataMigrator(DataMigrationTask): def build_assignments(self, map): assign = [] - for f1, f2 in map: - f2 = '`%s`' % f2 - f1 = '`%s`' % f1 + for e in map: + f2 = '`%s`' % e[1] + if len(e) > 2: + f1 = '%s(`%s`)' % (e[2], e[0]) + else: + f1 = '`%s`' % e[0] assign.append((f2, f1)) return assign diff --git a/trunk/import/migration/tasks/items.py b/trunk/import/migration/tasks/items.py index ed07c59..b00b67e 100644 --- a/trunk/import/migration/tasks/items.py +++ b/trunk/import/migration/tasks/items.py @@ -46,7 +46,7 @@ class ItemsCopyMigrator(DataMigrator): map = [ ('Face_Plage', 'track'), ('Cote_Phono', 'old_code'), - ('Duree', 'approx_duration'), + ('Duree', 'approx_duration', 'TIME_TO_SEC'), ('Titre_piece', 'title'), ('Transcrip_Trad', 'alt_title'), ('Auteur', 'author'),