Skip to content

V2 Migrate from postfixadmin

Andre Flemming edited this page Mar 17, 2016 · 2 revisions

Applies to ViMbAdmin v2 only! Deprecated in favour of ViMbAdmin v3.


Introduction

ViMbAdmin was designed to be compatible with Postfix Admin.

To use ViMbAdmin with your existing Postfix Admin database, you need to perform a small migration.

Install ViMbAdmin from Git as described on Install Using Git and then replace the database creation step with the below.

Warning

Before you start, backup your database.

The information is provided AS IS, without warranty.

Details

The MySQL migrations needed are as follows (YMMV):

ALTER TABLE  `admin` DROP PRIMARY KEY , ADD UNIQUE  `username` (  `username` );
ALTER TABLE  `admin` ADD  `id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
ALTER TABLE  `admin` ADD  `super` TINYINT( 1 ) NULL;
UPDATE admin SET `password` = SHA1( CONCAT( `password`, 'your_security_salt' ) ); // Works only with cleartext password.

// set one of your admin users to be a super

ALTER TABLE  `alias` DROP PRIMARY KEY , ADD UNIQUE  `address` (  `address` );
ALTER TABLE  `alias` ADD  `id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

ALTER TABLE  `domain` DROP PRIMARY KEY , ADD UNIQUE  `domain` (  `domain` );
ALTER TABLE  `domain` ADD  `id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

ALTER TABLE  `domain_admins` DROP  `active`;
ALTER TABLE  `domain_admins` ADD  `id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
RENAME TABLE  `domain_admins` TO  `domain_admin` ;


ALTER TABLE  `log` ADD  `id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
ALTER TABLE  `log` ADD INDEX  `username` (  `username` );
ALTER TABLE  `log` ADD INDEX  `domain` (  `domain` );

ALTER TABLE  `mailbox` DROP PRIMARY KEY , ADD UNIQUE  `username` (  `username` );
ALTER TABLE  `mailbox` ADD  `id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

ALTER TABLE `config` ADD COLUMN `created_at` datetime NOT NULL;
ALTER TABLE `config` ADD COLUMN `updated_at` datetime NOT NULL;

We have made some modifications over time to our Postfix Admin mailbox table. You should verify yours resembles:

CREATE TABLE `mailbox` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `maildir` varchar(255) DEFAULT NULL,
  `quota` bigint(20) NOT NULL DEFAULT '0',
  `local_part` varchar(255) NOT NULL,
  `domain` varchar(255) NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `homedir` varchar(255) DEFAULT NULL,
  `uid` bigint(20) DEFAULT NULL,
  `gid` bigint(20) DEFAULT NULL,
  `access_restriction` varchar(100) DEFAULT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`),
  KEY `domain_idx` (`domain`)
);

And create a new token table:

CREATE TABLE `token` (
    `id` bigint(20) NOT NULL auto_increment,
    `username` varchar(255) NOT NULL,
    `type` varchar(255) default NULL,
    `token` varchar(64) default NULL,
    `rid` varchar(64) default NULL,
    `created_at` datetime NOT NULL,
    PRIMARY KEY  (`id`),
    KEY `username_idx` (`username`)
);