[+] добавлены файлы миграций
This commit is contained in:
1 parent
c8374f1c7b
commit
1fb5f8382c
8 files changed
+264
No files matched your search
Generated
+7
@@ -8,5 +8,12 @@
|
||||
<jdbc-url>jdbc:mysql://its-dev.site:3306/delta_core</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
<data-source source="LOCAL" name="test.db" uuid="c1199c0a-fc79-4092-9eb0-f1273cdcbe20">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:D:\phpstorm\delta-project\test.db.db</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class Users extends AbstractMigration
|
||||
{
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
$this->table = 'd_users';
|
||||
$this->data = [
|
||||
[
|
||||
'active' => 'Y',
|
||||
'login' => 'admin',
|
||||
'password' => '7c607172d24d7237579acfdeffe373e2',
|
||||
'name' => 'Администратор',
|
||||
'email' => 'rsgrinko@yandex.ru',
|
||||
'email_confirmed' => 'Y',
|
||||
'verification_code' => null,
|
||||
'image_id' => 1,
|
||||
'token' => null,
|
||||
'last_active' => time(),
|
||||
'date_created' => date('Y-m-d H:i:s'),
|
||||
'date_updated' => null,
|
||||
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table($this->table);
|
||||
$table->addColumn('active', 'enum', ['values' => ['Y', 'N'], 'default' => 'Y', 'null' => false])
|
||||
->addColumn('login', 'string', ['limit' => 100, 'default' => null])
|
||||
->addColumn('password', 'string', ['limit' => 100, 'default' => null])
|
||||
->addColumn('name', 'string', ['limit' => 150, 'default' => null])
|
||||
->addColumn('email', 'string', ['limit' => 150, 'default' => null])
|
||||
->addColumn('email_confirmed', 'enum', ['values' => ['Y', 'N'], 'default' => 'N', 'null' => false])
|
||||
->addColumn('verification_code', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('image_id', 'integer', ['null' => true, 'default' => null])
|
||||
->addColumn('token', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('last_active', 'string', ['limit' => 100, 'default' => null])
|
||||
->addColumn('date_created', 'datetime', ['default' => 'CURRENT_TIMESTAMP'])
|
||||
->addColumn('date_updated', 'datetime', ['null' => true, 'default' => null])
|
||||
->addIndex(['login'])
|
||||
->addIndex(['token'])
|
||||
->addIndex(['email'])
|
||||
->create();
|
||||
$table->insert($this->data);
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class Roles extends AbstractMigration
|
||||
{
|
||||
public function init(): void
|
||||
{
|
||||
$this->table = 'd_roles';
|
||||
$this->data = [
|
||||
[
|
||||
'name' => 'Администраторы',
|
||||
'description' => 'Административная роль, имеет доступ ко всему',
|
||||
'date_created' => date('Y-m-d H:i:s'),
|
||||
'date_updated' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Система',
|
||||
'description' => 'Роль для системных пользователей',
|
||||
'date_created' => date('Y-m-d H:i:s'),
|
||||
'date_updated' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Доступ в панель администратора',
|
||||
'description' => 'Данная роль разрешает входить в панель администратора',
|
||||
'date_created' => date('Y-m-d H:i:s'),
|
||||
'date_updated' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Менеджеры',
|
||||
'description' => 'Административная роль с максимально урезанными правами',
|
||||
'date_created' => date('Y-m-d H:i:s'),
|
||||
'date_updated' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Пользователи',
|
||||
'description' => 'Базовая роль для простых зарегистрированных пользователей',
|
||||
'date_created' => date('Y-m-d H:i:s'),
|
||||
'date_updated' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table($this->table);
|
||||
$table->addColumn('name', 'text', ['default' => null])
|
||||
->addColumn('description', 'text', ['default' => null])
|
||||
->addColumn('date_created', 'datetime', ['default' => 'CURRENT_TIMESTAMP'])
|
||||
->addColumn('date_updated', 'datetime', ['null' => true, 'default' => null])
|
||||
->create();
|
||||
$table->insert($this->data);
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class UserRoles extends AbstractMigration
|
||||
{
|
||||
public function init(): void
|
||||
{
|
||||
$this->table = 'd_user_roles';
|
||||
$this->data = [
|
||||
[
|
||||
'user_id' => 1,
|
||||
'role_id' => 1,
|
||||
|
||||
],
|
||||
[
|
||||
'user_id' => 1,
|
||||
'role_id' => 3,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table($this->table);
|
||||
$table->addColumn('user_id', 'integer')
|
||||
->addColumn('role_id', 'integer')
|
||||
->create();
|
||||
$table->insert($this->data);
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class UserMeta extends AbstractMigration
|
||||
{
|
||||
public function init(): void
|
||||
{
|
||||
$this->table = 'd_user_meta';
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table($this->table);
|
||||
$table->addColumn('user_id', 'integer')
|
||||
->addColumn('name', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('value', 'text', ['default' => null])
|
||||
->addIndex(['user_id'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class Threads extends AbstractMigration
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->table = 'd_threads';
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table($this->table);
|
||||
$table->addColumn('active', 'enum', ['values' => ['Y', 'N'], 'default' => 'Y', 'null' => false])
|
||||
->addColumn('in_progress', 'enum', ['values' => ['Y', 'N'], 'default' => 'Y', 'null' => false])
|
||||
->addColumn('priority', 'integer', ['default' => 5])
|
||||
->addColumn('execution_time', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('attempts', 'integer', ['default' => 0])
|
||||
->addColumn('attempts_limit', 'integer', ['default' => 1])
|
||||
->addColumn('date_created', 'datetime', ['default' => 'CURRENT_TIMESTAMP'])
|
||||
->addColumn('date_updated', 'datetime', ['null' => true, 'default' => null])
|
||||
->addColumn('class', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('method', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('params', 'text', ['default' => null])
|
||||
->addColumn('status', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('response', 'text', ['default' => null])
|
||||
->addIndex(['active'])
|
||||
->addIndex(['in_progress'])
|
||||
->addIndex(['priority'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ThreadsHistory extends AbstractMigration
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->table = 'd_threads_history';
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table($this->table);
|
||||
$table->addColumn('task_id', 'integer')
|
||||
->addColumn('priority', 'integer', ['default' => 5])
|
||||
->addColumn('execution_time', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('attempts', 'integer', ['default' => 0])
|
||||
->addColumn('attempts_limit', 'integer', ['default' => 1])
|
||||
->addColumn('date_created', 'datetime', ['default' => 'CURRENT_TIMESTAMP'])
|
||||
->addColumn('date_updated', 'datetime', ['null' => true, 'default' => null])
|
||||
->addColumn('class', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('method', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('params', 'text', ['default' => null])
|
||||
->addColumn('status', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('response', 'text', ['default' => null])
|
||||
->addIndex(['task_id'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class Files extends AbstractMigration
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->table = 'd_files';
|
||||
$this->data = [
|
||||
[
|
||||
'name' => 'system.png',
|
||||
'path' => '/uploads/users/system.png',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table($this->table);
|
||||
$table->addColumn('name', 'string', ['limit' => 255, 'default' => null])
|
||||
->addColumn('path', 'text', ['default' => null])
|
||||
->create();
|
||||
$table->insert($this->data);
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user