Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | On-the-fly schema updates. No "fossil rebuild" needed when moving to Fossil 2.0. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | fossil-2.0 |
| Files: | files | file ages | folders |
| SHA1: |
94f4c0aab5678f83f82e5ee44876acd6 |
| User & Date: | drh 2017-02-28 14:14:32.438 |
Context
|
2017-02-28
| ||
| 16:25 | Refactoring and cleanup of some of the hash name interfaces. check-in: 1c8768b0de user: drh tags: fossil-2.0 | |
| 14:14 | On-the-fly schema updates. No "fossil rebuild" needed when moving to Fossil 2.0. check-in: 94f4c0aab5 user: drh tags: fossil-2.0 | |
| 10:12 | Update the change log for version 2.0. check-in: 89077b05bf user: drh tags: fossil-2.0 | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
1484 1485 1486 1487 1488 1489 1490 |
db_open_or_attach(g.zRepositoryName, "repository");
g.repositoryOpen = 1;
/* Cache "allow-symlinks" option, because we'll need it on every stat call */
g.allowSymlinks = db_get_boolean("allow-symlinks",
db_allow_symlinks_by_default());
g.zAuxSchema = db_get("aux-schema","");
| | < | < | < < < < | < < < < < < < < < < < < | 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 |
db_open_or_attach(g.zRepositoryName, "repository");
g.repositoryOpen = 1;
/* Cache "allow-symlinks" option, because we'll need it on every stat call */
g.allowSymlinks = db_get_boolean("allow-symlinks",
db_allow_symlinks_by_default());
g.zAuxSchema = db_get("aux-schema","");
/* If the ALIAS table is not present, then some on-the-fly schema
** updates might be required.
*/
if( !db_table_exists("repository","alias") ){
rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */
}
}
/*
** Flags for the db_find_and_open_repository() function.
*/
#if INTERFACE
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | ** This file contains code used to rebuild the database. */ #include "config.h" #include "rebuild.h" #include <assert.h> #include <errno.h> | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > > > | > | > > > > > > > > > > > | > > > > | > | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
** This file contains code used to rebuild the database.
*/
#include "config.h"
#include "rebuild.h"
#include <assert.h>
#include <errno.h>
/*
** Update the schema as necessary
*/
static void rebuild_update_schema(void){
/* Verify that the PLINK table has a new column added by the
** 2014-11-28 schema change. Create it if necessary. This code
** can be removed in the future, once all users have upgraded to the
** 2014-11-28 or later schema.
*/
if( !db_table_has_column("repository","plink","baseid") ){
db_multi_exec(
"ALTER TABLE repository.plink ADD COLUMN baseid;"
);
}
/* Verify that the MLINK table has the newer columns added by the
** 2015-01-24 schema change. Create them if necessary. This code
** can be removed in the future, once all users have upgraded to the
** 2015-01-24 or later schema.
*/
if( !db_table_has_column("repository","mlink","isaux") ){
db_begin_transaction();
db_multi_exec(
"ALTER TABLE repository.mlink ADD COLUMN pmid INTEGER DEFAULT 0;"
"ALTER TABLE repository.mlink ADD COLUMN isaux BOOLEAN DEFAULT 0;"
);
db_end_transaction(0);
}
/* Add the user.mtime column if it is missing. (2011-04-27)
*/
if( !db_table_has_column("repository", "user", "mtime") ){
db_multi_exec(
"CREATE TEMP TABLE temp_user AS SELECT * FROM user;"
"DROP TABLE user;"
"CREATE TABLE user(\n"
" uid INTEGER PRIMARY KEY,\n"
|
| ︙ | ︙ | |||
122 123 124 125 126 127 128 |
"INSERT OR IGNORE INTO user"
" SELECT uid, login, pw, cap, cookie,"
" ipaddr, cexpire, info, now(), photo FROM temp_user;"
"DROP TABLE temp_user;"
);
}
| | > | > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
"INSERT OR IGNORE INTO user"
" SELECT uid, login, pw, cap, cookie,"
" ipaddr, cexpire, info, now(), photo FROM temp_user;"
"DROP TABLE temp_user;"
);
}
/* Add the config.mtime column if it is missing. (2011-04-27)
*/
if( !db_table_has_column("repository", "config", "mtime") ){
db_multi_exec(
"ALTER TABLE config ADD COLUMN mtime INTEGER;"
"UPDATE config SET mtime=now();"
);
}
/* Add the shun.mtime and shun.scom columns if they are missing.
** (2011-04-27)
*/
if( !db_table_has_column("repository", "shun", "mtime") ){
db_multi_exec(
"ALTER TABLE shun ADD COLUMN mtime INTEGER;"
"ALTER TABLE shun ADD COLUMN scom TEXT;"
"UPDATE shun SET mtime=now();"
);
}
/* Add the reportfmt.mtime column if it is missing. (2011-04-27)
*/
if( !db_table_has_column("repository", "reportfmt", "mtime") ){
static const char zCreateReportFmtTable[] =
@ -- An entry in this table describes a database query that generates a
@ -- table of tickets.
@ --
@ CREATE TABLE IF NOT EXISTS reportfmt(
@ rn INTEGER PRIMARY KEY, -- Report number
@ owner TEXT, -- Owner of this report format (not used)
@ title TEXT UNIQUE, -- Title of this report
@ mtime INTEGER, -- Time last modified. Seconds since 1970
@ cols TEXT, -- A color-key specification
@ sqlcode TEXT -- An SQL SELECT statement for this report
@ );
;
db_multi_exec(
"CREATE TEMP TABLE old_fmt AS SELECT * FROM reportfmt;"
"DROP TABLE reportfmt;"
);
db_multi_exec("%s", zCreateReportFmtTable/*safe-for-%s*/);
db_multi_exec(
"INSERT OR IGNORE INTO reportfmt(rn,owner,title,cols,sqlcode,mtime)"
" SELECT rn, owner, title, cols, sqlcode, now() FROM old_fmt;"
"INSERT OR IGNORE INTO reportfmt(rn,owner,title,cols,sqlcode,mtime)"
" SELECT rn, owner, title || ' (' || rn || ')', cols, sqlcode, now()"
" FROM old_fmt;"
);
}
/* Add the concealed.mtime column if it is missing. (2011-04-27)
*/
if( !db_table_has_column("repository", "concealed", "mtime") ){
db_multi_exec(
"ALTER TABLE concealed ADD COLUMN mtime INTEGER;"
"UPDATE concealed SET mtime=now();"
);
}
/* Do the fossil-2.0 updates to the schema. (2017-02-28)
*/
rebuild_schema_update_2_0();
}
/*
** Update the repository schema for Fossil version 2.0. (2017-02-28)
** (1) Create the ALIAS table
** (2) Change the CHECK constraint on BLOB.UUID so that the length
** is greater than or equal to 40, not exactly equal to 40.
*/
void rebuild_schema_update_2_0(void){
static const char zCreateAliasTable[] =
@ -- Make sure the alias table exists.
@ --
@ CREATE TABLE repository.alias(
@ hval TEXT, -- Hex-encoded hash value
@ htype ANY, -- Type of hash.
@ rid INTEGER REFERENCES blob, -- Blob that this hash names
@ PRIMARY KEY(hval,htype,rid)
@ ) WITHOUT ROWID;
@ CREATE INDEX repository.alias_rid ON alias(rid);
;
char *z;
/* If the alias table is missing, create it. */
if( !db_table_exists("repository", "alias") ){
db_multi_exec("%s", zCreateAliasTable/*safe-for-%s*/);
}
/* Make sure the CHECK constraint on the BLOB table says "length(uuid)>=40"
** instead of "length(uuid)==40". */
z = db_text(0, "SELECT sql FROM repository.sqlite_master WHERE"
" name LIKE 'blob' AND sql LIKE '%%length(uuid)==40%%'");
if( z ){
|
| ︙ | ︙ | |||
194 195 196 197 198 199 200 |
z
);
break;
}
}
fossil_free(z);
}
| < | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
z
);
break;
}
}
fossil_free(z);
}
}
/*
** Variables used to store state information about an on-going "rebuild"
** or "deconstruct".
*/
static int totalSize; /* Total number of artifacts to process */
|
| ︙ | ︙ |