thedragoncode / laravel-deploy-operations Goto Github PK
View Code? Open in Web Editor NEW๐ Performing any actions during the deployment process
Home Page: https://deploy-operations.dragon-code.pro
License: MIT License
๐ Performing any actions during the deployment process
Home Page: https://deploy-operations.dragon-code.pro
License: MIT License
This likely won't impact many people at this stage, but I am in the process of upgrading from Laravel-Migration-Actions 2.x to Laravel-Actions 4.x, and ran into an issue because the BaseChangeColumn
migration uses $this->config->table
to determine the table name.
However, by 4.x, the configured default table name is 'actions' rather than 'migration_actions', and because of that, the changes in BaseChangeColumn
are not actually applied.
The result was that while php artisan migrate
appeared to work, but on the first run of php artisan actions
, it did not recognize that any of the actions had already run and tried to run them again. An SQL error then arose after the first action completed, because it could not save the action name/batch number into the database since the 'migration' field no longer existed:
[previous exception] [object] (PDOException(code: 42703): SQLSTATE[42703]: Undefined column: 7 ERROR: column \"action\" of relation \"actions\" does not exist
LINE 1: insert into \"actions\" (\"action\", \"batch\") values ($1, $2)
My solution was to add an additional migration in the app itself to make those changes -after- the rename was completed.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('actions', function (Blueprint $table) {
$table->renameColumn('migration', 'action');
$table->unsignedInteger('batch')->change();
});
}
};
php artisan migrate
followed by php artisan actions
after upgrading from 2.x to 4.x
Composer install fails when installing inside a fresh laravel 10 project
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- dragon-code/support[v6.0.1, ..., v6.11.0] require dragon-code/contracts ^2.18 -> found dragon-code/contracts[2.x-dev] but it does not match your minimum-stability.
- dragon-code/laravel-actions dev-main requires dragon-code/support ^6.6 -> satisfiable by dragon-code/support[v6.6.0, ..., v6.11.0].
- Root composer.json requires dragon-code/laravel-actions dev-main -> satisfiable by dragon-code/laravel-actions[dev-main].
Hello,
First of all, thank you for this bookshop, it is really useful. I would like to know if it was possible to add the isolated option to this package in the same way as laravel migration which allows launching the migration on a single server during a deployment on several servers.
Thanks in advance
Whenever I run the php artisan actions
command I get a warning "Actions repository already exists".
My migration actions execute properly, but I get the warning none-the-less.
Looking at the source code it looks like the Install
class is running the handle
function which generates this warning every time. It's unclear why it should run at all.
It's unclear, but I just updated from 2.x to using the migrate:actions:upgrade
command to 3.x, then to 4.x.
When Laravel suppresses migrations, it does not save the state of the executed actions.
We need to make sure that the changed actions are also saved to the upload file.
https://laravel.com/docs/8.x/migrations#squashing-migrations
Now the call of actions is carried out in one stage and you have to choose when to do it - before updating the symlink during zero-downtime deploy or after.
It is planned to add the possibility of a two-stage deployment.
For example with deployer:
task('deploy', [
// ...
'artisan:migrate',
'artisan:migrate:actions --before', // here
'deploy:publish',
'php-fpm:reload',
'artisan:queue:restart',
'artisan:migrate:actions', // here
]);
No response
For example:
up
or down
method;success
method.Now, when creating a file, you must enter the name yourself to form the file. It would be cool to do it automatically.
How will it look like:
If you don't fill in the name parameter when creating the command, it should automatically generate a name for the file.
As a prefix, can take the current branch name from the repository, if it exists.
For example,
# with git
php artisan make:migration:action
// 2022_01_28_184116_main_1643384476.php
// 2022_01_28_184117_main_1643384477.php
// 2022_01_28_184118_crm_2345_1643384478.php
// 2022_01_28_184119_crm_2345_1643384479.php
# without git
php artisan make:migration:action
// 2022_01_28_184116_auto_1643384476.php
// 2022_01_28_184117_auto_1643384477.php
// 2022_01_28_184118_auto_1643384478.php
// 2022_01_28_184119_auto_1643384479.php
# with name parameter
php artisan make:migration:action FooBar
// 2022_01_28_184116_foo_bar.php
// 2022_01_28_184117_foo_bar.php
// 2022_01_28_184118_foo_bar.php
// 2022_01_28_184119_foo_bar.php
The idea is that if the developer does not need meaningful names, then auto-creation can be applied, leaving only the check of the current active branch in the repository.
Calling migrations allows you to execute one file:
php artisan migrate --path=2021_12_06_144806_test.php
php artisan migrate --path=custom/directory/2021_12_06_144806_test.php
We need to add the same functionality to invoke actions but with a features:
php artisan migrate --file=2021_12_06_144806_test.php
php artisan migrate --file=custom/directory/2021_12_06_144806_test.php
// or
php artisan migrate --file=2021_12_06_144806_test
php artisan migrate --file=custom/directory/2021_12_06_144806_test
For example:
up
or down
method;finish
method.mysql
Currently the detection of the anonymous migrations feature is not ideal since anonymous migrations has been introduced in Laravel 8.37 and the code checks if the major version of the app is 9.
Create Laravel >8.37 project, create anonymous migration and try to migrate. It will fail.
I have a subfolder within my actions folder that does not contain Action classes.. example:
By Running php artisan migrate:actions
I get the following error:
DragonCode\LaravelActions\Services\Migrator::resolveAction(): Return value must be of type DragonCode\LaravelActions\Action, int returned
I think files that do not extend Action
shouldn't be taken into account or files that don't start with xxxx_xx_xx_xxxxx_.....
etc...
Create any file within a subfolder inside the actions directory and run php artisan migrate:actions
Is it possible to publish the migration file?
For example:
up
or down
method;failed
method.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.