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 key_store;
23class system_path;
24
25std::string describe_sql_schema(sqlite3 * db);
26void check_sql_schema(sqlite3 * db, system_path const & filename);
27void migrate_sql_schema(sqlite3 * db, key_store & keys,
28 system_path const & filename);
29
30// utility routine shared with database.cc
31void assert_sqlite3_ok(sqlite3 * db);
32
33// debugging
34void test_migration_step(sqlite3 * db, key_store & keys,
35 system_path const & filename,
36 std::string const & schema);
37
38// this constant is part of the database schema, but it is not in schema.sql
39// because sqlite expressions can't do arithmetic on character values. it
40// is stored in the "user version" field of the database header. when we
41// encounter a database whose schema hash we don't recognize, we look for
42// this code in the header to decide whether it's a monotone database or
43// some other sqlite3 database. the expectation is that it will never need
44// to change. we call it a creator code because it has the same format and
45// function as file creator codes in old-sk00l Mac OS.
46
47const unsigned int mtn_creator_code = ((('_'*256 + 'M')*256 + 'T')*256 + 'N');
48
49// Local Variables:
50// mode: C++
51// fill-column: 76
52// c-file-style: "gnu"
53// indent-tabs-mode: nil
54// End:
55// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
56
57#endif // __SCHEMA_MIGRATION__

Archive Download this file

Branches

Tags

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