~zeitgeist/zeitgeist/saucy-packaging-0-9-14

« back to all changes in this revision

Viewing changes to extensions/fts++/sql-schema.vala

  • Committer: Package Import Robot
  • Author(s): Didier Roche, 11.04 → 12.04 upgrade
  • Date: 2012-05-03 14:28:29 UTC
  • Revision ID: package-import@ubuntu.com-20120503142829-79ij3euvsxl8icuy
Tags: 0.9.0-1ubuntu1
* debian/patches/01_upstream_cherry_picks.patch:
  - picks some upstream fixes:
  zeitgeist-fts crashed with SIGSEGV in fast_validate()
  (LP: #981300, #954171)
  [11.04 → 12.04 upgrade] Dash is always empty due to zeitgeist crash:
  Unable to upgrade from schema version 3 (LP: #986191)

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
                    Timestamp.now ());
58
58
                exec_query (database, schema_sql);
59
59
            }
60
 
            else if (schema_version == 4 || schema_version == 5)
 
60
            else if (schema_version >= 3 && schema_version <= 5)
61
61
            {
62
62
                backup_database ();
63
63
 
 
64
                if (schema_version == 3)
 
65
                {
 
66
                    // Add missing columns to storage table
 
67
                    exec_query (database,
 
68
                        "ALTER TABLE storage ADD COLUMN icon VARCHAR");
 
69
                    exec_query (database,
 
70
                        "ALTER TABLE storage ADD COLUMN display_name VARCHAR");
 
71
 
 
72
                    // Set subjects that don't have a storage to "unknown", so
 
73
                    // they'll always be marked as available.
 
74
                    // FIXME: Do we want to separate unknown/local/online?
 
75
                    exec_query (database, """
 
76
                        INSERT OR IGNORE INTO storage (value, state)
 
77
                            VALUES ('unknown', 1)
 
78
                        """);
 
79
                    exec_query (database, """
 
80
                        UPDATE event SET subj_storage =
 
81
                            (SELECT id FROM storage WHERE value='unknown')
 
82
                        WHERE subj_storage IS NULL
 
83
                        """);
 
84
 
 
85
                    // The events table is missing two columns, (event) origin
 
86
                    // and subj_current_id. It needs to be replaced.
 
87
                    exec_query (database,
 
88
                        "ALTER TABLE event RENAME TO event_old");
 
89
                }
 
90
 
64
91
                string[] tables = { "interpretation", "manifestation",
65
92
                    "mimetype", "actor" };
66
93
 
84
111
                    exec_query (database, "DROP TABLE %s_old".printf (table));
85
112
                }
86
113
 
 
114
                if (schema_version == 3)
 
115
                {
 
116
                    // Migrate events from the old table
 
117
                    exec_query (database, """
 
118
                        INSERT INTO event
 
119
                        SELECT
 
120
                            id, timestamp, interpretation, manifestation,
 
121
                            actor, payload, subj_id, subj_interpretation,
 
122
                            subj_manifestation, subj_origin, subj_mimetype,
 
123
                            subj_text, subj_storage, NULL as origin,
 
124
                            subj_id AS subj_id_current
 
125
                         FROM event_old
 
126
                         """);
 
127
 
 
128
                    // This will also drop any triggers the `events' table had
 
129
                    exec_query (database, "DROP TABLE event_old");
 
130
                }
 
131
 
87
132
                // Ontology update
88
133
                exec_query (database,
89
134
                    "INSERT OR IGNORE INTO manifestation (value) VALUES ('%s')"