Could not find migration class for migration step symfony doctrine - doctrine

I am trying to migrate back to a previous step, I have accidentally deleted my current migration step '56'. When I run
php symfony doctrine:migrate 51
As expected, it throws an error "Could not find migration class for migration step: 56" -- this is due to me deleting the migration 56 class
What is the solution to roll back to the previous step "51", without having the current class already there
I am using an older version of symfony v 1.2

I fixed this issue by accessing the localhost/phpmyadmin and locating the table called 'migration version'
I ran a quick update query, and change the value to '51'
As follows
UPDATE `migration_version` SET `version`=51 WHERE 1
I hope this helps people in the future

Related

Sulu, strange hash related error when trying to save page / post?

Until recently everything was working well. Now, when I try to save (create or update) any page or post I get error message at top of the form "Error - There was an error when trying to save the form".
In error log I see this error:
“Uncaught PHP Exception Sulu\Component\Rest\Exception\InvalidHashException: “The given hash for the entity of type “Sulu\Bundle\ArticleBundle\Document\ArticleDocument” with the id “9e0720a7-5565-4a6f-a735-8a186b8fef9b” does not match the current hash. The entity has probably been edited in the mean time.” at /var/www/html/vendor/sulu/sulu/src/Sulu/Component/Hash/RequestHashChecker.php line 53"
Tried clearing symfony cache, website cache from admin, restarting docker containers.
I'm totally unaware that I did something to cause this error. Please help.
Update: strange thing I just noticed. When I try to save some article and I get that error and go back to overview page (where i.e. all articles of that type are listed) then I see unchanged article title. But when I click to edit it I see changed title?!? Like title on overview page and title on edit page are not used from the same place? How is that possible?
Update:
Now even I setup once more project from scratch saving articles causes that error. Some more info:
In stack trace last command executed is:
in vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php (line 64)
an it shoots out “No alive nodes found in your cluster”.
And while I'm setting up the project when executing:
php bin/console ongr:es:index:create
I get error:
{"error":{"root_cause":[{"type":"resource_already_exists_exception","reason
":"index [su_articles/sWs5F1uzSFO8bFiZqF1Egw] already exists","index_uuid":
"sWs5F1uzSFO8bFiZqF1Egw","index":"su_articles"}],"type":"resource_already_e
xists_exception","reason":"index [su_articles/sWs5F1uzSFO8bFiZqF1Egw] alrea
dy exists","index_uuid":"sWs5F1uzSFO8bFiZqF1Egw","index":"su_articles"},"st
atus":400}
And when I run:
php bin/console ongr:es:index:create --manager=live
I get similar:
In Connection.php line 675:
{"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [su_articles_live/Pissm9ycRj-o79K4wrrD
AA] already exists","index_uuid":"Pissm9ycRj-o79K4wrrDAA","index":"su_articles_live"}],"type":"resource_already_exists_exc
eption","reason":"index [su_articles_live/Pissm9ycRj-o79K4wrrDAA] already exists","index_uuid":"Pissm9ycRj-o79K4wrrDAA","i
ndex":"su_articles_live"},"status":400}
Also to mention that now saving pages works, but saving articles doesn't.
This solved the issue on ElasticSearch index creation for me:
php bin/console ongr:es:index:drop --force
The error can happen in the following cases.
Expected Case somebody else did edit the same article like you and did save it
Unexpected Case your phpcr cache is not in sync
Unexpected Case you have a multi server setup but your cache.app is not configured to use a central cache
So if its one of the unexpected cases first you should clear your cache.pools with:
bin/console cache:pool:prune
If you have a multi server setup make sure you configure a central cache. Most use in this case a redis-server which you configure in your cache.yaml e.g.:
# config/packages/prod/cache.yaml
framework:
cache:
default_redis_provider: "%env(resolve:REDIS_DSN)%"
app: cache.adapter.redis
Also make sure that you use the latest version and maybe update your phpcr cache configuration based on the sulu/skeleton: https://github.com/sulu/skeleton/blob/2.x/config/packages/prod/sulu_document_manager.yaml, there you could when performance doesn't matter in your case disable the phpcr cache, I would not recommend that.

Fatal:Class Illuminate\Routing\RouteCollection contains 1 abstract method and must therefore be declared abstract or implement the remaining methods

I didn't change any backend code .I dont know it triggers when I hit any url of laravel app it will show this error.I dont know why this happend and also need solution for this .My laravel version in 5.8 and php 7.2
Fatal error : Class Illuminate\Routing\RouteCollection contains 1 abstract method and must therefore be declared abstract or implement the remaining methods C:\xampp\htdocs\pmf\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php on line 14 this is file it is saying.
Reinstall or update composer wont solve the problem. In my case, you just need to restart the local development server, because the problem is just temporary.
Just need to restart the local development server.

Artisan rollback, Undefined index (file missing)

I'm trying to do a rollback in Laravel 5.4. I deleted a file manually from the migrations folder. Now when I try to rollback I get an error:
[root#xxx]# php artisan migrate:rollback
[ErrorException]
Undefined index: 2017_08_22_204640_create_tasks_table
That file was a test (with a controller and a view), but I'm new on Laravel and didn't know that deleting that file manually would be a problem.
How can repair that now?
Edit: The main goal is to rename a column from a table made with migrations.
I made this migration file:
[root#xxx]# php artisan make:migration rename_nombre_generadora_column --table="admin_generadora" --create
Created Migration: 2017_08_24_160600_rename_nombre_generadora_column
But then I saw that the name of the table was wrong, should be admin_generadoras. I wanted to create a new migration file but I got this error:
[root#xxx]# php artisan make:migration rename_nombre_generadora_column --table="admin_generadoras" --create
[InvalidArgumentException]
A RenameNombreGeneradoraColumn migration already exists.
So how can I undo that migration?
In situations like this I always tend to simply delete whole database and run "correct" migrations again. You have seeds right? You have factories right?
I copy some text I have written before:
Note for migrations and how to do it right (IMHO):
always use migrations to create and update database schema
if you are a lone developer AND there is no production environment set up, just amend the migrations and do database reset (remove all tables) + migrate
if you are a team OR there is production environment already set up, always create new migration
do not bother with down() method that much
Some material from creator & friends of Laravel regarding migrations can be heard in this podcast http://www.laravelpodcast.com/episodes/68236-episode-53-bigger-better around 30 minute mark.
What you need to do now is to understand deeply how migrations work! To do that you need to take a look at migrations table and play with it; play with artisan and migrations related commands. And remember you can update/amend database schema with SQL (that means using some kind of database client like PhpMyAdmin) but also amend/update corresponding migration.
the --table flag just helps you fill out the migration file faster. Just go in to the RenameNombreGeneradoraColumn file and change admin_generadora to admin_generadoras

laravel not reading autoload_classmap.php?

I'm having problems in one of my dev environments that I thought I had tracked down to a problem with the autoload_classmap.php file, but now I'm not so sure. I'm having a hard time tracking it any further and, frankly, my experience with the laravel forums has been an absolute joke, so I thought I'd ask here.
Usually after I change git branches in my local development environment, I get the following error trying to load up my site:
Fatal error: Class 'Illuminate\Config\EnvironmentVariables' not found in /home/username/projects/project-name/vendor/laravel/framework/src/Illuminate/Foundation/start.php on line 119
Call Stack:
0.0000 231784 1. {main}() /home/username/projects/project-name/public/index.php:0
0.0181 1464432 2. require_once('/home/username/projects/project-name/bootstrap/start.php') /home/username/projects/project-name/public/index.php:35
0.0233 2006416 3. require('/home/username/projects/project-name/vendor/laravel/framework/src/Illuminate/Foundation/start.php') /home/username/projects/project-name/bootstrap/start.php:84
The class name changes every time I run the installation. Originally, I tracked the problem down to the fact that composer dump-autoload wouldn't update the autoload_classmap.php file to include any of the Illuminate classes. Once I figured out I needed to run composer install instead, I found those classes in the class map...but I'm still getting that error, despite that line showing up in my class map and pointing to the right location:
'Illuminate\\Config\\EnvironmentVariables' => $vendorDir . '/laravel/framework/src/Illuminate/Config/EnvironmentVariables.php',
I'm finally at the point where I can't seem to get my environment running at all. Last time this happened it took three separate times recreating my environment until things magically started working. Can anyone point me in the right direction to troubleshoot why files that are showing up in my classmap still aren't loading? Is there a log I can check? Is there some combination of composer commands I can run to get everything running?

Laravel ClassLoader trying to load an old version of my model

So a while back I decided to redo one of my models in Laravel completely, but I wanted to hold on to the original copy of the file just in case. So I renamed it to something like MyModel (OLD).php and left it there in the models folder next to the new model.
Now that I understand Laravel a bit better, I realize that wasn't a great idea, but in any case everything seemed to work for months. Then today, I made a minor update (modifying a database query) to one of the functions in my new model and suddenly Laravel is trying to load the old copy of my model. I finally moved the old copy out of the models folder and into a backup folder completely outside of my laravel application, but now Laravel throws the error:
include(pathToMyModels/MyModel (OLD).php): failed to open stream: No such file or directory
referring to this section of ClassLoader.php
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}
I tried undoing the modification to the model, changing the route and controller function name, clearing laravel's cache, clearing the browser cache, using different browsers, but nothing seems to work except to manually include the model's php file before calling the class it contains. What can I do to get Laravel to automatically recognize my model like it does all the others I have?
Try to clear composer cache and then run composer dump-autoload.
composer clear-cache
composer dump-autoload
if you don't want to run commands then try this one, i think it's solve your problem.
goto your laravel_project_folder\vendor\composer
now open the file autoload_classmap.php and autoload_static.php in your text editor
and find your old/backup file name line
and rename with actual filename and correct their path.
now run your project again and check for the error occurance, i think your problem is solved.
i just knew that my laravel using old controller after 1 hour of debuging. what time waste
i tried accepted answer but still persist
i delete the controller and recreate, now works
copy all the code
delete the controller
make http request to that controller (404)
create file same name
paste in

Resources