From: Jan Schneider Date: Mon, 13 Dec 2010 18:33:40 +0000 (+0100) Subject: Convert to migrations. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b63f899bf1a047c3b3fb9233922c35a6fdfb6afb;p=horde.git Convert to migrations. --- diff --git a/vilma/migration/1_vilma_base_tables.php b/vilma/migration/1_vilma_base_tables.php new file mode 100644 index 000000000..8bda2894d --- /dev/null +++ b/vilma/migration/1_vilma_base_tables.php @@ -0,0 +1,75 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package Vilma + */ +class VilmaBaseTables extends Horde_Db_Migration_Base +{ + /** + * Upgrade. + */ + public function up() + { + $tableList = $this->tables(); + + if (!in_array('vilma_domains', $tableList)) { + $t = $this->createTable('vilma_domains', array('primaryKey' => 'domain_id')); + $t->column('domain_id', 'integer', array('null' => false)); + $t->column('domain_name', 'string', array('limit' => 128, 'null' => false)); + $t->column('domain_transport', 'string', array('limit' => 128, 'null' => false)); + $t->column('domain_max_users', 'integer', array('default' => 0, 'null' => false)); + $t->column('domain_quota', 'integer', array('default' => 0, 'null' => false)); + $t->column('domain_key', 'string', array('limit' => 64)); + $t->end(); + + $this->addIndex('vilma_domains', 'domain_name', array('unique' => true)); + } + + if (!in_array('vilma_users', $tableList)) { + $t = $this->createTable('vilma_users', array('primaryKey' => 'user_id')); + $t->column('user_id', 'integer', array('null' => false)); + $t->column('user_name', 'string', array('limit' => 255, 'null' => false)); + $t->column('user_clear', 'string', array('limit' => 255, 'null' => false)); + $t->column('user_crypt', 'string', array('limit' => 255, 'null' => false)); + $t->column('user_full_name', 'string', array('limit' => 255, 'null' => false)); + $t->column('user_uid', 'integer', array('null' => false)); + $t->column('user_gid', 'integer', array('null' => false)); + $t->column('user_home_dir', 'string', array('limit' => 255, 'null' => false)); + $t->column('user_mail_dir', 'string', array('limit' => 255, 'null' => false)); + $t->column('user_mail_quota', 'integer', array('default' => 0, 'null' => false)); + $t->column('user_ftp_dir', 'string', array('limit' => 255, 'null' => false)); + $t->column('user_ftp_quota', 'integer', array('default' => 0, 'null' => false)); + $t->column('user_enabled', 'integer', array('default' => 1, 'null' => false)); + $t->end(); + + $this->addIndex('vilma_users', 'user_name', array('unique' => true)); + } + + if (!in_array('vilma_virtuals', $tableList)) { + $t = $this->createTable('vilma_virtuals', array('primaryKey' => 'virtual_id')); + $t->column('virtual_id', 'integer', array('null' => false)); + $t->column('virtual_email', 'string', array('limit' => 128, 'null' => false)); + $t->column('virtual_destination', 'string', array('limit' => 128, 'null' => false)); + $t->end(); + } + } + + /** + * Downgrade to 0 + */ + public function down() + { + $this->dropTable('vilma_domains'); + $this->dropTable('vilma_users'); + $this->dropTable('vilma_virtuals'); + } +} diff --git a/vilma/scripts/sql/vilma.sql b/vilma/scripts/sql/vilma.sql deleted file mode 100644 index 9dac04cc6..000000000 --- a/vilma/scripts/sql/vilma.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE vilma_domains ( - domain_id INT DEFAULT 0 NOT NULL, - domain_name VARCHAR(128) DEFAULT '' NOT NULL, - domain_transport VARCHAR(128) DEFAULT '' NOT NULL, - domain_max_users INT DEFAULT 0 NOT NULL, - domain_quota INT DEFAULT 0 NOT NULL, - domain_key VARCHAR(64), --- - PRIMARY KEY (domain_id), - UNIQUE (domain_name) -); - -CREATE TABLE vilma_users ( - user_id INT DEFAULT 0 NOT NULL, - user_name VARCHAR(255) DEFAULT '' NOT NULL, - user_clear VARCHAR(255) DEFAULT '' NOT NULL, - user_crypt VARCHAR(255) DEFAULT '' NOT NULL, - user_full_name VARCHAR(255) DEFAULT '' NOT NULL, - user_uid INT NOT NULL, - user_gid INT NOT NULL, - user_home_dir VARCHAR(255) DEFAULT '' NOT NULL, - user_mail_dir VARCHAR(255) DEFAULT '' NOT NULL, - user_mail_quota INT DEFAULT 0 NOT NULL, - user_ftp_dir VARCHAR(255) DEFAULT NULL, - user_ftp_quota INT DEFAULT NULL, - user_enabled SMALLINT DEFAULT 1 NOT NULL, --- - PRIMARY KEY (user_id), - UNIQUE (user_name) -); - -CREATE TABLE vilma_virtuals ( - virtual_id INT DEFAULT 0 NOT NULL, - virtual_email VARCHAR(128) DEFAULT '' NOT NULL, - virtual_destination VARCHAR(128) DEFAULT '' NOT NULL, --- - PRIMARY KEY (virtual_id) -);