monotone

monotone Mtn Source Tree

Root/schema_migration.hh

1#ifndef __SCHEMA_MIGRATION__
2#define __SCHEMA_MIGRATION__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13
14// this file knows how to migrate schema databases. the general strategy is
15// to hash each schema we ever use, and make a list of the SQL commands
16// required to get from one hash value to the next. when you do a
17// migration, the migrator locates your current db's state on the list and
18// then runs all the migration functions between that point and the target
19// of the migration.
20
21struct sqlite3;
22class app_state;
23class system_path;
24
25void migrate_sql_schema(sqlite3 * db, app_state & app);
26void check_sql_schema(sqlite3 * db, system_path const & filename);
27std::string describe_sql_schema(sqlite3 * db);
28
29// utility routine shared with database.cc
30void assert_sqlite3_ok(sqlite3 * db);
31
32// debugging
33void test_migration_step(sqlite3 * db, app_state & app,
34 std::string const & schema);
35
36// this constant is part of the database schema, but it is not in schema.sql
37// because sqlite expressions can't do arithmetic on character values. it
38// is stored in the "user version" field of the database header. when we
39// encounter a database whose schema hash we don't recognize, we look for
40// this code in the header to decide whether it's a monotone database or
41// some other sqlite3 database. the expectation is that it will never need
42// to change. we call it a creator code because it has the same format and
43// function as file creator codes in old-sk00l Mac OS.
44
45const unsigned int mtn_creator_code = ((('_'*256 + 'M')*256 + 'T')*256 + 'N');
46
47// Local Variables:
48// mode: C++
49// fill-column: 76
50// c-file-style: "gnu"
51// indent-tabs-mode: nil
52// End:
53// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
54
55#endif // __SCHEMA_MIGRATION__

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status