Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- conn = new SQLConnection();
- make_vcs_db_query = file_read(\Kickback\SCRIPT_ROOT . "/../meta/schema/kickback-kingdom-schema.mysql");
- // Replace the schema name: `kickbackdb` -> `kickbackdb_vcs`
- // (Ideally, we'd do this in a more syntax-aware way.
- // Perhaps we could get mysqldump to parameterize the database name?
- // Then we could parameterize the query instead of using fragile hacky regex stuff.)
- make_vcs_db_query ~= s/\bkickbackdb\b/kickbackdb_vcs/g;
- // Create the `kickbackdb_vcs` database.
- conn.execute(make_vcs_db_query);
- // Query that finds tables that exist in local database (kickbackdb) but not in VCS database (kickbackdb_vcs).
- results = conn.execute("...");
- diff.add_to_tables_removed(results);
- // Query that finds tables that exist in VCS database (kickbackdb_vcs) but not in local database (kickbackdb).
- results = conn.execute("...");
- diff.add_to_tables_added(results);
- // Query that finds tables that exist in BOTH databases.
- table_list = conn.execute("...");
- foreach( table in table_list )
- {
- // Query that finds columns that exist in the local table, but not in the VCS table.
- results = conn.execute("...");
- diff.add_to_columns_removed(table, results);
- // Query that finds columns that exist in the VCS table, but not in the local table.
- results = conn.execute("...");
- diff.add_to_columns_added(table, results);
- // Query that finds keys that exist in the local table, but not in the VCS table.
- results = conn.execute("...");
- diff.add_to_keys_removed(table, results);
- // Query that finds keys that exist in the VCS table, but not in the local table.
- results = conn.execute("...");
- diff.add_to_keys_added(table, results);
- // ditto for any other table-level entities
- // Also you may want to diff for any data-level differences if the data
- // is something semantically significant in code.
- // (We should avoid semantically-signficant data as much as possible,
- // though things like badges in the current site ARE this kind of thing.)
- // So, like, adding a new badge type should probably appear in the diff.
- }
- // ditto for things like triggers, views, etc
- // Query that deletes kickbackdb_vcs
- conn.execute("...");
- // Present the difference to the admin
- display_diff(diff);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement