Коммит c6e2c071 создал по автору Иванов Игорь Антонович's avatar Иванов Игорь Антонович 💬
Просмотр файлов

Describe the reason for your commit here

владельцы
build: docker-compose -f docker-compose.yml build ${c} up: docker-compose -f docker-compose.yml up -d ${c} start: docker-compose -f docker-compose.yml start ${c} down: docker-compose -f docker-compose.yml down ${c} stop: docker-compose -f docker-compose.yml stop ${c} restart: docker-compose -f docker-compose.yml stop ${c} docker-compose -f docker-compose.yml up -d ${c} logs: docker-compose -f docker-compose.yml logs --tail=100 -f ${c} logs-web: docker-compose -f docker-compose.yml logs --tail=100 -f backend ps: docker ps login-db: docker-compose -f docker-compose.yml exec db /bin/bash login-web: docker-compose -f docker-compose.yml exec backend /bin/bash migrate: docker exec -it bc_backend ./vendor/bin/phinx migrate -e default migration: docker exec -it bc_backend ./vendor/bin/phinx create ${name} restart-supervisor: docker exec -it bc_backend supervisorctl restart all
\ Нет новой строки в конце файла
<code_scheme name="Default" version="173">
<DBN-PSQL>
<case-options enabled="true">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="true">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
<PHPCodeStyleSettings>
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
<option name="ALIGN_PHPDOC_COMMENTS" value="true" />
<option name="ALIGN_ASSIGNMENTS" value="true" />
<option name="COMMA_AFTER_LAST_ARRAY_ELEMENT" value="true" />
<option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" />
<option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />
<option name="GROUP_USE_WRAP" value="0" />
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
<option name="LOWER_CASE_NULL_CONST" value="true" />
<option name="ELSE_IF_STYLE" value="SEPARATE" />
<option name="ALIGN_CLASS_CONSTANTS" value="true" />
<option name="KEEP_BLANK_LINES_AFTER_LBRACE" value="1" />
<option name="SPACE_BEFORE_CLOSURE_LEFT_PARENTHESIS" value="false" />
<option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
<option name="NEW_LINE_AFTER_PHP_OPENING_TAG" value="true" />
</PHPCodeStyleSettings>
<codeStyleSettings language="JSON">
<indentOptions>
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="PHP">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="CLASS_BRACE_STYLE" value="1" />
<option name="METHOD_BRACE_STYLE" value="1" />
<option name="ELSE_ON_NEW_LINE" value="false" />
<option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="ALIGN_GROUP_FIELD_DECLARATIONS" value="true" />
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
<option name="ARRAY_INITIALIZER_WRAP" value="2" />
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
<indentOptions>
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="Twig">
<indentOptions>
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
\ Нет новой строки в конце файла
Локальная установка
------------
**Первый запуск docker-compose (Сборка проекта)**
>`
docker-compose up -d --build
`
Установка начальных данных
>`
docker exec -it ttc_backend php cli.php install data verbose
`
Разворачиваем базу автомобилей
>`
docker exec -it ttc_backend php cli.php cars_base_parse parse verbose
`
Запускаем фронтенд
>`
docker exec -i ttc_backend bash -c "cd public/spa/ && npm run serve"
`
-------------
[Public interface](http://localhost:8080/user/) (Login: `+79990000000`) (код из смс смотрим в консоли)
[Admin panel](http://localhost:8080/admin/) (Login: `admin@admin.admin`, Password: `123456`)
-----------
Разработка
-----------
**Действия с контейнерами**
Запуск проекта: `docker-compose up -d`
Остановка проекта: `docker-compose stop`
Перезапуск определенного контейнера: `docker-compose restart <ИМЯ_КОНТЕЙНЕРА>`
Вход в терминал определенного контейнера: `docker exec -it <ИМЯ_КОНТЕЙНЕРА> bash`
-----------
**Composer**
Ручное обновление композера:
>`
docker exec -it ttc_backend composer update
`
-----------
**Phinx (Миграции)**
Создать файл миграции (создает файл в папке `apps/backend/database/migrations`):
>`
docker exec -it ttc_backend php vendor/bin/phinx create <НазваниеМиграции>
`
Запуск миграции:
>`
docker exec -it ttc_backend php vendor/bin/phinx migrate -e default
`
-----------
**Палнировщик**
Список запущенных задач:
>`
docker exec -it ttc_backend php vendor/bin/crunz schedule:list
`
------------
**CLI Команды**
Очистка кэша и мета-даты моделей (когда произошли изменения в модельках или в любой не понятной ситуации :о)
>`
docker exec -it ttc_backend php cli.php cache flushModelsMetadata
`
Сгенерировать языковой файл (запускать после изменений в языковых настройках админки, генерирует языковой файл для мобилки и фронта)
>`
docker exec -it ttc_backend php cli.php multi_lang generate verbose
`
Фронтенд
--------
Сборка SPA
>`
docker exec -i ttc_backend bash -c "cd public/spa/ && npm run build"
`
\ Нет новой строки в конце файла
<?php
use App\Helpers\CliColors;
use Phalcon\Cli\Console;
use Phalcon\Cli\Dispatcher;
use Phalcon\Di\FactoryDefault\Cli;
require __DIR__ . '/src/config/defines.php';
$config = require CONFIG_PATH . 'config.php';
$config->cli = true;
require CONFIG_PATH . 'loader.php';
require 'vendor/autoload.php';
require CONFIG_PATH . 'sentry.php';
$container = new Cli();
$providers = require CONFIG_PATH . '/providers.php';
foreach($providers as $provider) {
if(
$provider === 'App\Providers\ConfigProvider' ||
$provider === 'App\Providers\DbProvider' ||
$provider === 'App\Providers\RedisProvider' ||
$provider === 'App\Providers\FilesystemProvider'
) {
$container->register(new $provider());
}
}
$console = new Console();
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('App\Cli\Tasks');
$dispatcher->setNamespaceName('App\Cli\Tasks');
$container->setShared('dispatcher', $dispatcher);
$console->setDI($container);
$arguments = [];
foreach($argv as $k => $arg){
if($k === 1){
$arguments['task'] = $arg;
} else if($k === 2){
$arguments['action'] = $arg;
} else if($k >= 3){
$arguments['params'][] = $arg;
}
}
$container->set('console', $console);
try {
$console->handle($arguments);
} catch(\Exception $exception){
Sentry\captureException($exception);
$colors = new CliColors();
if($exception->getCode() === 2) $error = 'Task "' . $arguments['task'] . '" undefined' . PHP_EOL;
else if($exception->getCode() === 5) $error = 'Action "' . $arguments['action'] . '" in task "' . $arguments['task'] . '" undefined' . PHP_EOL;
else $error = $exception->getMessage();
echo $colors->getColoredString($error, 'red');
exit(255);
}
\ Нет новой строки в конце файла
{
"name": "bazcom/student-ttc",
"description": "TakToCar Project",
"minimum-stability": "dev",
"type": "project",
"authors": [
{
"name": "Ruslan Gromov",
"email": "ruslan.gromov@bazcom.pro"
}
],
"require": {
"enqueue/pheanstalk": "^0.9.7",
"enqueue/sqs": "0.9.8",
"guzzlehttp/guzzle": "^6.3",
"guzzlehttp/psr7": "1.8.4",
"jan-swiecki/simple-annotations": "0.3.1",
"lavary/crunz": "v2.0.3",
"league/flysystem": "^1.1@dev",
"league/flysystem-aws-s3-v3": "^1.0@dev",
"league/flysystem-cached-adapter": "dev-master",
"nesbot/carbon": "^2.16.1",
"php-http/message": "1.8.0",
"phpunit/phpunit": "^7.5.8",
"predis/predis": "~v1.1.1",
"queue-interop/queue-interop": "0.8.0",
"robmorgan/phinx": "^0.10.6",
"sentry/sdk": "2.1.0",
"symfony/console": "3.4.27",
"symfony/process": "v4.2.12",
"swiftmailer/swiftmailer": "^6.2",
"telegram-bot/api": "^2.3",
"web-token/jwt-framework": "1.3.x-dev",
"jenssegers/agent": "v2.6.4",
"ext-json": "*"
},
"require-dev": {
"phalcon/devtools": "4.1.x-dev",
"doctrine/common": "2.9.*",
"zircote/swagger-php": "^3.0",
"phalcon/ide-stubs": "v4.1.0"
},
"scripts": {
"clear-cache": [
"php cli.php cache flushModelsMetadata true",
"php cli.php cache clearAssets true"
]
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
<?php
use App\Helpers\CliColors;
use App\Services\MessageQueue;
use App\Services\TelegramBot;
use Carbon\Carbon;
use Enqueue\Pheanstalk\PheanstalkConnectionFactory;
use Enqueue\Pheanstalk\PheanstalkMessage;
$queueName = $argv[1];
if(empty($queueName)){
echo 'Queue name is required' . PHP_EOL;
exit(255);
}
require __DIR__ . '/src/config/defines.php';
$config = require CONFIG_PATH . 'config.php';
$config->cli = true;
require CONFIG_PATH . 'loader.php';
require 'vendor/autoload.php';
require CONFIG_PATH . 'sentry.php';
$factory = new PheanstalkConnectionFactory([
'host' => $config->queue->beanstalkd->host,
'port' => $config->queue->beanstalkd->port,
]);
$queueContext = new MessageQueue($factory->createContext());
$queue = $queueContext->createQueue($queueName);
$consumer = $queueContext->createConsumer($queue);
$bot = new TelegramBot($config->telegram_bot->token, $config->telegram_bot->main_chat_id, $queueContext, $config->telegram_bot->send_messages);
$bot->setProxy($config->telegram_bot->proxy);
$colors = new CliColors();
$print = function($text, $color) use ($colors): void {
echo $colors->getColoredString(Carbon::now()->toDateTimeString(), 'light_gray') . ' ' . $colors->getColoredString($text, $color) . PHP_EOL;
};
$print('Started in ' . $config->env . ' environment', 'blue');
$consoleTaskCounter = 0;
while(true){
try {
/**
* @var PheanstalkMessage $message
*/
$message = $consumer->receive();
if($message !== null && $message->getHeader('cli', false)){
$consoleTaskCounter++;
$task = $message->getHeader('task', 'main');
$action = $message->getHeader('action', 'main');
$print($consoleTaskCounter . ') Start handle ' . $task . ':' . $action, 'blue');
$handleParams = [
'task' => $task,
'action' => $action,
'params' => $message->getProperties(),
];
$handleStr = base64_encode(serialize($handleParams));
$shell = 'php /var/www/cli.php main handle ' . $handleStr;
$workerMessages = [];
exec($shell, $workerMessages, $status);
$print(
$consoleTaskCounter . ') ' . ($status === 0 ? 'Successful' : 'Error') . ' handled ' . $task . ':' . $action . (count($workerMessages) > 0 ? ' with messages:' : ''),
($status === 0 ? 'blue' : 'red')
);
if(count($workerMessages) > 0) foreach($workerMessages as $workerMessage){
echo '----| ' . $workerMessage . PHP_EOL;
}
if($status === 0){
$consumer->acknowledge($message);
} else {
if(!$message->isRedelivered()){
$delayTime = 60;
$message->setDelay($delayTime);
$consumer->reject($message, true);
$print($consoleTaskCounter . ') Task ' . $task . ':' . $action . ' repeat after ' . $delayTime . 's in second time', 'blue');
} else {
$consumer->reject($message);
$print($consoleTaskCounter . ') Task ' . $task . ':' . $action . ' rejected after 2 attempts', 'red');
$bot->writeOrEditMessageToMainChatInBackground(
$consoleTaskCounter . ') Task *' . $task . ':' . $action . '* rejected after *2* attempts',
null,
'markdown',
false, null, true
);
}
}
}
} catch(Throwable $exception){
$print('CONSUMER ERROR: ' . $exception->getMessage(), 'red');
\Sentry\captureException($exception);
$bot->writeOrEditMessageToMainChatInBackground(
'*CONSUMER ERROR*: ' . $exception->getMessage(),
null,
'markdown',
false, null, true
);
}
}
\ Нет новой строки в конце файла
* * * * * cd /var/www/ && vendor/bin/crunz schedule:run /var/www/src/cli >> /var/www/logs/cron.log
# Crunz Configuration Settings
# This option defines where the task files and
# directories reside.
# The path is relative to the project's root directory,
# where the Crunz is installed (Trailing slashes will be ignored).
source: src/cli
# The suffix is meant to target the task files inside the ":source" directory.
# Please note if you change this value, you need
# to make sure all the existing tasks files are renamed accordingly.
suffix: Cron.php
# Timezone is used to calculate task run time
# This option is very important and not setting it is deprecated
# and will result in exception in 2.0 version.
timezone: UTC
# This option define which timezone should be used for log files
# If false, system default timezone will be used
# If true, the timezone in config file that is used to calculate task run time will be used
timezone_log: false
# By default the errors are not logged by Crunz
# You may set the value to true for logging the errors
log_errors: false
# This is the absolute path to the errors' log file
# You need to make sure you have the required permission to write to this file though.
errors_log_file: logs/cron.log
# By default the output is not logged as they are redirected to the
# null output.
# Set this to true if you want to keep the outputs
log_output: false
# This is the absolute path to the global output log file
# The events which have dedicated log files (defined with them), won't be
# logged to this file though.
output_log_file:
# This option determines whether the output should be emailed or not.
email_output: false
# This option determines whether the error messages should be emailed or not.
email_errors: false
# Global Swift Mailer settings
#
mailer:
# Possible values: smtp, mail, and sendmail
transport: smtp
recipients:
sender_name:
sender_email:
# SMTP settings
#
smtp:
host:
port:
username:
password:
encryption:
\ Нет новой строки в конце файла
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class StartMigration extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('user');
$table->addColumn('last_name', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('first_name', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('middle_name', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('phone', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('email', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('login', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('password', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('avatar', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('birth_date', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ])
->addColumn('passport_data', PostgresAdapter::PHINX_TYPE_JSONB, [ 'null' => true ])
->addColumn('driver_license_data', PostgresAdapter::PHINX_TYPE_JSONB, [ 'null' => true ])
->addColumn('comment', PostgresAdapter::PHINX_TYPE_TEXT, [ 'null' => true ])
->addColumn('is_change_password', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('type', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('status', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$table->addIndex([ 'phone', 'email', 'login' ]);
$table->create();
}
}
<?php
use Phinx\Migration\AbstractMigration;
class AddUniquePhone extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('user');
$table->truncate();
$table->addIndex('phone', ['unique' => true]);
$table->update();
}
}
<?php
use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\PostgresAdapter;
class NewTabs extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
// create table admin
$table = $this->table('admin');
$table->addColumn('last_name', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('first_name', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('middle_name', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('phone', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('email', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('login', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('password', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$table->addIndex([ 'phone', 'login' ]);
$table->create();
// create table settings
$table = $this->table('configuration');
$table->addColumn('ver_app', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('ver_api', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('tech_works', PostgresAdapter::PHINX_TYPE_INTEGER, ['default' => 0])
->addColumn('tech_works_reason', PostgresAdapter::PHINX_TYPE_TEXT, ['null' => true])
->addColumn('tech_works_start', PostgresAdapter::PHINX_TYPE_DATETIME, ['null' => true])
->addColumn('tech_works_end', PostgresAdapter::PHINX_TYPE_DATETIME, ['null' => true])
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$table->create();
//crete table faq
$table = $this->table('faq');
$table->addColumn('question', PostgresAdapter::PHINX_TYPE_TEXT)
->addColumn('answer', PostgresAdapter::PHINX_TYPE_TEXT)
->addColumn('author_id', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('editor_id', PostgresAdapter::PHINX_TYPE_INTEGER, [ 'null' => true ])
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$table->addForeignKey('author_id' , 'admin')
->addForeignKey('editor_id' , 'admin');
$table->create();
}
}
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class Car extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
// create table Search
$table = $this->table('car');
$table->addColumn('user_id', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('mark', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('model', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('release_year', PostgresAdapter::PHINX_TYPE_INTEGER, [ 'null' => true ])
->addColumn('engine_size', PostgresAdapter::PHINX_TYPE_FLOAT, [ 'null' => true ])
->addColumn('body_type', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('seat_numbers', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('tyres_type', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('longitude', PostgresAdapter::PHINX_TYPE_FLOAT, [ 'null' => true ])
->addColumn('latitude', PostgresAdapter::PHINX_TYPE_FLOAT, [ 'null' => true ])
->addColumn('status', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('car_number', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('mileage', PostgresAdapter::PHINX_TYPE_INTEGER, [ 'null' => true ])
->addColumn('osago_number', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('pts', PostgresAdapter::PHINX_TYPE_INTEGER, [ 'null' => true ])
->addColumn('sts', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('osago_end_date', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('images', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('description', PostgresAdapter::PHINX_TYPE_TEXT, [ 'null' => true ])
->addColumn('address_id', PostgresAdapter::PHINX_TYPE_INTEGER, [ 'null' => true ])
->addColumn('region', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('city', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('metro', PostgresAdapter::PHINX_TYPE_STRING, [ 'null' => true ])
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$table->addIndex(['region', 'city', 'address_id']);
$table->create();
}
}
<?php
use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\PostgresAdapter;
class OrderTable extends AbstractMigration
{
public function change()
{
$table = $this->table('order');
$table->addColumn('user_id', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('car_id', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('start_date', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('end_date', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('total_price', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('commission', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('status', PostgresAdapter::PHINX_TYPE_INTEGER, ['default' => 0])
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$table->create();
}
}
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class OptionTables extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('car_option');
$table->addColumn('car_id', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('option_id', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('price', PostgresAdapter::PHINX_TYPE_INTEGER)
->addColumn('status', PostgresAdapter::PHINX_TYPE_INTEGER, ['default' => 0])
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$table->create();
$table = $this->table('option');
$table->addColumn('name', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$table->create();
}
}
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class ChangeStartTables extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$configuration = $this->table('configuration');
$configuration
->changeColumn('ver_app', PostgresAdapter::PHINX_TYPE_STRING)
->changeColumn('ver_api', PostgresAdapter::PHINX_TYPE_STRING);
$configuration->update();
$car = $this->table('car');
$car
->changeColumn('pts', PostgresAdapter::PHINX_TYPE_STRING)
->changeColumn('sts', PostgresAdapter::PHINX_TYPE_STRING)
->changeColumn('osago_number', PostgresAdapter::PHINX_TYPE_STRING)
->changeColumn('car_number', PostgresAdapter::PHINX_TYPE_STRING);
$car->update();
}
}
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class NewConfig extends AbstractMigration
{
public function change()
{
$this->table('configuration')->drop()->save();
$configuration = $this->table('configuration');
$configuration->addColumn('key', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('value', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$configuration->addIndex('key', ['unique' => true]);
$configuration->create();
}
}
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class AddTypeToConfig extends AbstractMigration
{
public function change()
{
$configuration = $this->table('configuration');
$configuration->addColumn('type', PostgresAdapter::PHINX_TYPE_INTEGER, ['default' => 0]);
$configuration->update();
}
}
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class StatusToFaq extends AbstractMigration {
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change() {
$table = $this->table('faq');
$table->addColumn('status', PostgresAdapter::PHINX_TYPE_INTEGER, ['default' => 1]);
$table->update();
}
}
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class AddCommentToCar extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
// create table Search
$table = $this->table('car');
$table->addColumn('comment', PostgresAdapter::PHINX_TYPE_TEXT, [ 'null' => true ]);
$table->update();
}
}
<?php
use Phinx\Db\Adapter\PostgresAdapter;
use Phinx\Migration\AbstractMigration;
class CreateAddressTable extends AbstractMigration
{
public function change()
{
$address = $this->table('address');
$address
->addColumn('fias_id', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('region_code', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('full', PostgresAdapter::PHINX_TYPE_STRING)
->addColumn('region_iso_code', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('region_with_type', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('area_with_type', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('city_with_type', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('metro', PostgresAdapter::PHINX_TYPE_JSON, ['null' => true])
->addColumn('street_with_type', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('house', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('block', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('postal_code', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('okato', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('oktmo', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('kladr', PostgresAdapter::PHINX_TYPE_STRING, ['null' => true])
->addColumn('created_at', PostgresAdapter::PHINX_TYPE_DATETIME)
->addColumn('updated_at', PostgresAdapter::PHINX_TYPE_DATETIME, [ 'null' => true ]);
$address->create();
}
}
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать