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

Archive Download this file

Branches

Tags

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