raspisms/db/migrations/20191206123238_first_migrat...

829 lines
29 KiB
PHP
Executable File

<?php
use Phinx\Db\Adapter\MysqlAdapter;
class FirstMigration extends Phinx\Migration\AbstractMigration
{
public function change()
{
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
$this->table('command', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('name', 'string', [
'null' => false,
'limit' => 25,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addColumn('script', 'string', [
'null' => false,
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'name',
])
->addColumn('admin', 'boolean', [
'null' => false,
'limit' => MysqlAdapter::INT_TINY,
'after' => 'script',
])
->addIndex(['id_user', 'name'], [
'name' => 'id_user',
'unique' => true,
])
->create();
$this->table('conditional_group', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('name', 'string', [
'null' => false,
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addColumn('condition', 'text', [
'null' => false,
'limit' => 65535,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'name',
])
->addIndex(['id_user', 'name'], [
'name' => 'id_user',
'unique' => true,
])
->create();
$this->table('contact', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('name', 'string', [
'null' => false,
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addColumn('number', 'string', [
'null' => false,
'limit' => 20,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'name',
])
->addColumn('datas', 'text', [
'null' => true,
'limit' => 65535,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'number',
])
->addIndex(['id_user', 'name'], [
'name' => 'id_user',
'unique' => true,
])
->create();
$this->table('event', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('type', 'string', [
'null' => false,
'limit' => 25,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addColumn('at', 'timestamp', [
'null' => false,
'default' => 'CURRENT_TIMESTAMP',
'after' => 'type',
])
->addColumn('text', 'string', [
'null' => false,
'limit' => 255,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'at',
])
->addIndex(['id_user'], [
'name' => 'id_user',
'unique' => false,
])
->create();
$this->table('group', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('name', 'string', [
'null' => false,
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addIndex(['id_user', 'name'], [
'name' => 'id_user',
'unique' => true,
])
->create();
$this->table('group_contact', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_group', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('id_contact', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id_group',
])
->addIndex(['id_group'], [
'name' => 'id_group',
'unique' => false,
])
->addIndex(['id_contact'], [
'name' => 'id_contact',
'unique' => false,
])
->create();
$this->table('media', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_scheduled', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('path', 'string', [
'null' => false,
'limit' => 1000,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_scheduled',
])
->addIndex(['id_scheduled'], [
'name' => 'id_scheduled',
'unique' => false,
])
->create();
$this->table('phone', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('number', 'string', [
'null' => false,
'limit' => 25,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addColumn('adapter', 'string', [
'null' => false,
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'number',
])
->addColumn('adapter_datas', 'text', [
'null' => true,
'limit' => 65535,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'adapter',
])
->addIndex(['id_user'], [
'name' => 'id_user',
'unique' => false,
])
->create();
$this->table('received', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('at', 'datetime', [
'null' => false,
'after' => 'id',
])
->addColumn('text', 'string', [
'null' => false,
'limit' => 1000,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'at',
])
->addColumn('origin', 'string', [
'null' => false,
'limit' => 20,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'text',
])
->addColumn('destination', 'string', [
'null' => true,
'limit' => 20,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'origin',
])
->addColumn('command', 'boolean', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_TINY,
'after' => 'destination',
])
->addColumn('status', 'enum', [
'null' => false,
'default' => 'unread',
'limit' => 6,
'values' => ['read', 'unread'],
'after' => 'command',
])
->create();
$this->table('scheduled', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('origin', 'string', [
'null' => true,
'limit' => 25,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addColumn('at', 'datetime', [
'null' => false,
'after' => 'origin',
])
->addColumn('text', 'string', [
'null' => false,
'limit' => 1000,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'at',
])
->addColumn('flash', 'boolean', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_TINY,
'after' => 'text',
])
->addIndex(['id_user'], [
'name' => 'id_user',
'unique' => false,
])
->create();
$this->table('scheduled_conditional_group', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_scheduled', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('id_conditional_group', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id_scheduled',
])
->addIndex(['id_scheduled'], [
'name' => 'id_scheduled',
'unique' => false,
])
->addIndex(['id_conditional_group'], [
'name' => 'id_conditional_group',
'unique' => false,
])
->create();
$this->table('scheduled_contact', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_scheduled', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('id_contact', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id_scheduled',
])
->addIndex(['id_scheduled'], [
'name' => 'id_scheduled',
'unique' => false,
])
->addIndex(['id_contact'], [
'name' => 'id_contact',
'unique' => false,
])
->create();
$this->table('scheduled_group', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_scheduled', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('id_group', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id_scheduled',
])
->addIndex(['id_scheduled'], [
'name' => 'id_scheduled',
'unique' => false,
])
->addIndex(['id_group'], [
'name' => 'id_group',
'unique' => false,
])
->create();
$this->table('scheduled_number', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_scheduled', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('number', 'string', [
'null' => false,
'limit' => 20,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_scheduled',
])
->addIndex(['id_scheduled'], [
'name' => 'id_scheduled',
'unique' => false,
])
->create();
$this->table('sended', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('at', 'datetime', [
'null' => false,
'after' => 'id',
])
->addColumn('text', 'string', [
'null' => false,
'limit' => 1000,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'at',
])
->addColumn('origin', 'string', [
'null' => false,
'limit' => 20,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'text',
])
->addColumn('destination', 'string', [
'null' => true,
'limit' => 20,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'origin',
])
->addColumn('flash', 'boolean', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_TINY,
'after' => 'destination',
])
->addColumn('status', 'enum', [
'null' => false,
'default' => 'unknown',
'limit' => 9,
'values' => ['unknown', 'delivered', 'failed'],
'after' => 'flash',
])
->create();
$this->table('setting', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('name', 'string', [
'null' => false,
'limit' => 50,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addColumn('value', 'string', [
'null' => false,
'limit' => 1000,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'name',
])
->addIndex(['id_user', 'name'], [
'name' => 'id_user',
'unique' => true,
])
->create();
$this->table('smsstop', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('number', 'string', [
'null' => false,
'limit' => 20,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addIndex(['id_user', 'number'], [
'name' => 'id_user',
'unique' => true,
])
->create();
$this->table('user', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('email', 'string', [
'null' => false,
'limit' => 150,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id',
])
->addColumn('password', 'string', [
'null' => false,
'limit' => 255,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'email',
])
->addColumn('admin', 'boolean', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_TINY,
'after' => 'password',
])
->addColumn('transfer', 'boolean', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_TINY,
'after' => 'admin',
])
->addIndex(['email'], [
'name' => 'email',
'unique' => true,
])
->create();
$this->table('validation', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('token', 'string', [
'null' => false,
'limit' => 200,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id',
])
->addColumn('random', 'string', [
'null' => false,
'limit' => 32,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'token',
])
->addColumn('action', 'string', [
'null' => false,
'limit' => 200,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'random',
])
->addColumn('datas', 'text', [
'null' => false,
'limit' => 65535,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'action',
])
->create();
$this->table('webhook', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('id_user', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('url', 'string', [
'null' => false,
'limit' => 250,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id_user',
])
->addColumn('type', 'enum', [
'null' => false,
'limit' => 11,
'values' => ['send_sms', 'receive_sms'],
'after' => 'url',
])
->addIndex(['id_user'], [
'name' => 'id_user',
'unique' => false,
])
->create();
$this->table('webhook_querie', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'COMPACT',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'identity' => 'enable',
])
->addColumn('url', 'string', [
'null' => false,
'limit' => 250,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id',
])
->addColumn('datas', 'string', [
'null' => false,
'limit' => 10000,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'url',
])
->create();
}
}