I've been troubleshooting this error with no luck.
TemplateSyntaxError at /signup/
Caught DatabaseError while rendering: relation "signup_product" does not exist
LINE 1: ..."duration", "signup_product"."duration_type" FROM "signup_pr...
What I've discovered is when I run manage.py syncdb, it is not creating any tables in my database. This is an empty database, which explains the above error.
I ran manage.py sqlall myapp and it displayed all the models in myapp.models
I can start the shell and import myapp just fine.
So why doesn't manage.py syncdb create my tables?
This is before I learned about South. I wasn't using migrate, so syncdb wasn't adding my new models.
Related
I need your help. Days ago I created the following migration:
2022_07_28_144638_create_projects_table.php
Obviously it is not the last because I have created several. Now I have added onDelete ('cascade') on the following line:
$table-> foreign('client_id') -> references('id') -> on('clients') -> onDelete('cascade');
so since it was added after now I have to do a migrate on the same migration again.
I need to figure out how to do this. I'm new to Laravel.
If you are in the local environment, you should use the following command.
php artisan migrate:rollback
then update migration code
$table->foreignId('client_id')->references('id')->constrained('clients')->cascadeOnDelete();
then
php artisan migrate
I want to create a tbl_teacher_students table using migration..
My command is php artisan make:migration create_tbl_teacher_students_table.
I also tried adding --create=tbl_teacher_students but both gives me this error:
PHP Fatal error: Cannot declare class CreateFailedJobsTable, because the name is already in use
Symfony\Component\ErrorHandler\Error\FatalError
Cannot declare class CreateFailedJobsTable, because the name is already in use
I can't find anything about CreateFailedJobsTable error relating to migration.
Additional, I also tried adding column to an existing table but it gave me the same error.
This is happening, because on your database/migrataions/ directory create_failed_jobs_table..... created twice. Delete one. Then run composer dump-autoload and try again. This will solve the problem
Starting from a fresh project:
laravel new new-project
cd new-project
touch storage/database/database.sqlite
Then at .env
DB_CONNECTION=sqlite
DB_DATABASE=storage/database/database.sqlite
DB_FOREIGN_KEYS=true
The migration succeed...
php artisan migrate
php artisan tinker
>>>App\User::all()
But when I try to get all users it returns the following error:
PHP Fatal error: Class 'App/User' not found in Psy Shell code on line 1
What I could be missing?
Recently I reinstalled Laravel...
And I didn't realized I was using version Laravel 8
the models are at /app/Models
So the right command would be:
>>>App\Models\User::all()
i think it has something to do with the namespace alias. Try without the App/
Users::all();
Consider
laravel new bug
Then adding in .env
DB_CONNECTION=sqlite
DB_DATABASE=/home/me/Code/bug/storage/database.sqlite
creating database
touch /home/me/Code/bug/storage/database.sqlite
migrating
php artisan migrate && php artisan migrate:fresh
Now trying to migrate programmatically in tinker
php artisan tinker
>> Artisan::call('migrate');
First time resulting in => 0 (as expected ?) But second time:
>>> Artisan::call('migrate:fresh')
Illuminate\Database\QueryException with message 'SQLSTATE[HY000]:
General error: 17 database schema has changed (SQL: select * from
sqlite_master where type = 'table' and name = migrations)'
Artisan::call('migrate')
Third time:
Symfony\Component\Console\Exception\CommandNotFoundException with
message 'There are no commands defined in the "migrate" namespace.'
Any ideas whats going on here? Can you reproduce?
Update using postgres. The second time running Artisan::call('migrate:fresh') I get:
Symfony\Component\Console\Exception\CommandNotFoundException with
message 'There are no commands defined in the "migrate" namespace.'
UPDATE 2: Issue filed here: https://github.com/laravel/framework/issues/22997
https://github.com/laravel/tinker/issues/37
I don't think if this is a laravel bug, but I found your problem:
Calling a non existing command like Artisan::call('migrate:fresh') will crash. The reason is a typo: tinker does not accept fresh, only refresh. Calling the command via tinker will empty the sqllite file so you can't execute any commands until you migrate without tinker.
Here are my steps:
php artisan migrate # sqllite file is filled with content
php artisan tinker
> Artisan:call('refresh')
> Artisan::call('fresh') # now the sqllite file is empty
> Artisan::call('migrate') # will crash
php artisan migrate
> Artisan::('refresh') # works
so I think it's a tinker bug, not a laravel one. Tinker is doing some kind of snapshot (If you change a Model you have to restart tinker to call it there), maybe the error handling is not implemented is the best way to catch all errors.
I have created an application in laravel using appzcoder crud-generator plug-in. i have done everything accordingly but i am getting the above mentioned error. I have a folder named layouts in views folder and this folder has app.stub in it. but when i run the project it gives the following error
View [layouts.app] not found. (View:C:\wamp64\www\myProject\resources\views\admin\items\index.blade.php)
make sure you have run below code if not run it will create layout.app path
or manually create view/layout/app.php
php artisan vendor:publish --provider="Appzcoder\CrudGenerator\CrudGeneratorServiceProvider"