aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/migration.php
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-07-15 11:57:53 -0400
committerNathan Guse <nathaniel.guse@gmail.com>2013-01-09 16:39:59 -0600
commitf817e20f287a21e2dddfba9721f5e02dce162d29 (patch)
treef78eec7bd0b090fb564048b87d01669b155e1627 /phpBB/includes/db/migration.php
parent0e9b7bcae98ec5f864ad8f183ded4fc0040cec28 (diff)
downloadforums-f817e20f287a21e2dddfba9721f5e02dce162d29.tar
forums-f817e20f287a21e2dddfba9721f5e02dce162d29.tar.gz
forums-f817e20f287a21e2dddfba9721f5e02dce162d29.tar.bz2
forums-f817e20f287a21e2dddfba9721f5e02dce162d29.tar.xz
forums-f817e20f287a21e2dddfba9721f5e02dce162d29.zip
[feature/migrations] Basic migrations with schema and data changes
The migrator takes care of applying migrations as necessary. RFC: http://area51.phpbb.com/phpBB/viewtopic.php?f=84&t=41337 PHPBB3-9737
Diffstat (limited to 'phpBB/includes/db/migration.php')
-rw-r--r--phpBB/includes/db/migration.php79
1 files changed, 79 insertions, 0 deletions
diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php
new file mode 100644
index 0000000000..f96fcb9568
--- /dev/null
+++ b/phpBB/includes/db/migration.php
@@ -0,0 +1,79 @@
+<?php
+/**
+*
+* @package db
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Abstract base class for database migrations
+*
+* Each migration consists of a set of schema and data changes to be implemented
+* in a subclass. This class provides various utility methods to simplify editing
+* a phpBB.
+*
+* @package db
+*/
+class phpbb_db_migration
+{
+ var $db;
+ var $db_tools;
+
+ /**
+ * Migration constructor
+ *
+ * @param dbal $db Connected database abstraction instance
+ * @param phpbb_db_tools $db_tools Instance of db schema manipulation tools
+ */
+ function phpbb_db_migration(&$db, &$db_tools)
+ {
+ $this->db = &$db;
+ $this->db_tools = &$db_tools;
+ }
+
+ /**
+ * Defines other migrationsto be applied first (abstract method)
+ *
+ * @return array An array of migration class names
+ */
+ function depends_on()
+ {
+ return array();
+ }
+
+ /**
+ * Updates the database schema
+ *
+ * @return null
+ */
+ function update_schema()
+ {
+ }
+
+ /**
+ * Updates data
+ *
+ * @return null
+ */
+ function update_data()
+ {
+ }
+
+ /**
+ * Adds a column to a database table
+ */
+ function db_column_add($table_name, $column_name, $column_data)
+ {
+ $this->db_tools->sql_column_add($table_name, $column_name, $column_data);
+ }
+}