From 1fb5f8382c4cc55de10ee22004e7b552a0412837 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Mon, 10 Apr 2023 09:26:08 +0300 Subject: [PATCH] =?UTF-8?q?[+]=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BC?= =?UTF-8?q?=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dataSources.xml | 7 +++ db/migrations/20230405185037_users.php | 53 ++++++++++++++++++ db/migrations/20230405185040_roles.php | 56 +++++++++++++++++++ db/migrations/20230405185041_user_roles.php | 33 +++++++++++ db/migrations/20230405185044_user_meta.php | 22 ++++++++ db/migrations/20230405185104_threads.php | 34 +++++++++++ .../20230405185109_threads_history.php | 31 ++++++++++ db/migrations/20230405185125_files.php | 28 ++++++++++ 8 files changed, 264 insertions(+) create mode 100644 db/migrations/20230405185037_users.php create mode 100644 db/migrations/20230405185040_roles.php create mode 100644 db/migrations/20230405185041_user_roles.php create mode 100644 db/migrations/20230405185044_user_meta.php create mode 100644 db/migrations/20230405185104_threads.php create mode 100644 db/migrations/20230405185109_threads_history.php create mode 100644 db/migrations/20230405185125_files.php diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 660f23d..94734fd 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -8,5 +8,12 @@ jdbc:mysql://its-dev.site:3306/delta_core $ProjectFileDir$ + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:D:\phpstorm\delta-project\test.db.db + $ProjectFileDir$ + \ No newline at end of file diff --git a/db/migrations/20230405185037_users.php b/db/migrations/20230405185037_users.php new file mode 100644 index 0000000..263d011 --- /dev/null +++ b/db/migrations/20230405185037_users.php @@ -0,0 +1,53 @@ +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(); + } +} diff --git a/db/migrations/20230405185040_roles.php b/db/migrations/20230405185040_roles.php new file mode 100644 index 0000000..c76c1d8 --- /dev/null +++ b/db/migrations/20230405185040_roles.php @@ -0,0 +1,56 @@ +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(); + } +} diff --git a/db/migrations/20230405185041_user_roles.php b/db/migrations/20230405185041_user_roles.php new file mode 100644 index 0000000..e319a98 --- /dev/null +++ b/db/migrations/20230405185041_user_roles.php @@ -0,0 +1,33 @@ +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(); + } +} diff --git a/db/migrations/20230405185044_user_meta.php b/db/migrations/20230405185044_user_meta.php new file mode 100644 index 0000000..209c838 --- /dev/null +++ b/db/migrations/20230405185044_user_meta.php @@ -0,0 +1,22 @@ +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(); + } +} diff --git a/db/migrations/20230405185104_threads.php b/db/migrations/20230405185104_threads.php new file mode 100644 index 0000000..4d3a330 --- /dev/null +++ b/db/migrations/20230405185104_threads.php @@ -0,0 +1,34 @@ +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(); + } +} diff --git a/db/migrations/20230405185109_threads_history.php b/db/migrations/20230405185109_threads_history.php new file mode 100644 index 0000000..ae95ccc --- /dev/null +++ b/db/migrations/20230405185109_threads_history.php @@ -0,0 +1,31 @@ +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(); + } +} diff --git a/db/migrations/20230405185125_files.php b/db/migrations/20230405185125_files.php new file mode 100644 index 0000000..e663565 --- /dev/null +++ b/db/migrations/20230405185125_files.php @@ -0,0 +1,28 @@ +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(); + } +}