I install laravel and create project.
I Configed configuration file database and create database in mysql(mysql runnig in wamp server).
I want use migrate for create table in mysql,but i should wait a lot of time and see error.
What shoud i do?
This could help you run these command in terminal:
php artisan migrate --force
The migrate:refresh will roll back all of your migrations then execute the migrate command.this will re-creates your entire database.
php artisan migrate:refresh
This will absolutely help you,run this command:
php artisan migrate:fresh
if it did't help please chick out this:
https://laravel.com/docs/5.7/migrations
Probably you entered your mysql Server credentials in the database config, but you have to edit the .env file. Values in there overwrite config settings.
Related
Is it possible to create schemas automatically in the database when xampp is turning on? There is no information about it in the Laravel documentation, documentation says only how to do it manually by writing the command php artisan migrate.
Xampp includes a script called apache_startup.bat in the root directory, you can add the following line to it
c:\xampp\php\php.exe -f /path/to/laravel/app/artisan migrate
Then when the apache server starts, it should run that the equivalent of php artisan migrate to setup the database.
You can do php artisan make:migration [migration-name] - other than that, you have to fill the rest yourself.
It is not mentioned in the docs and in the CLI help, it says - Creates the Migration Repository.
What does that mean?
When I run thus command it says - database laravel not found.
Laravel creates a migrations table in your database to keep track of what migrations have already been ran on your database. If you run php artisan migrate:install, this table is created.
This table makes sure that when you run php artisan migrate, migrations that have already been ran on the database are not done again.
When migrating, this table is also created automatically, there is no need to run the install command beforehand.
The reason for your error is probably because you have not set the correct database credentials in either your .env file or config/database.php file.
sorry for silly question but I'm really facing problem. After migrating all the migration files. When I need another features for my project I have to make another table but When I'm going to migrate the new table using "php artisan migrate:rollback" or "php artisan migrate:rollback step=17" .... all the migration files are migrating this time too and I am losing all previous data. Then How can I migrate only the new one?
To migrate only new migrations is simple: php artisan migrate. The way the process works is that Laravel creates a table in your database called migrations. In that table are the names of the migrations that have been run already. If there are new migrations the above command will work.
You can read more about running migrations in the documentation.
To migrate any new migration created php artisan migrate is the artisan command.
To get the details of all commands php artisan is the artisan command.
To get the details of any specific command php artisan help command-name-here.
In the case of creating a new file, you only need to run php artisan migrate again.
If you want modify original migration file and migrate it again, you can use this package to migrate.
First, install package in your Laravel project:
composer require caloskao/migrate-specific
Register command at app/Console/Kernel.php :
protected $commands = [
\CalosKao\MigrateSpecific::class
];
Now, run this command to migrate your file
php artisan migrate:specific database/migrations/table.php
I am using Laravel 5.3.I deleted one of my migration files name 'feature' and everything related to it very carefully like its id from other tables etc.then i manually deleted the table from database.But now while i'm running the command "php artisan migrate:refresh".It's showing error exception with 'undefined index:***_create_features_table'.And when I'm running just 'php artisan migrate'.it shows that it was successful and all the tables successfully appear in the database.but then when i run migrate:refresh all the table disappears.what should i do to completely delete the migration file?
Try this.
First Manually delete the migration file under app/database/migrations/my_migration_file_name.php
Reset the composer autoload files: composer dump-autoload
Modify your database: Remove the last entry from the migrations table
Here is what I did.I cleared all the data from the database including all tables and then ran 'php artisan migrate'..that is how i made it work..But i am looking for a better solution which will not need to delete everything from the database.
Try check that you have the correct migrations first
php artisan migrate:status
Then you can try something like
php artisan migrate:refresh --step=1
And check again the status.
If you have Undefined index error and your migration was made with --path option, then add to your ModuleServiceProvier boot() method:
$this->loadMigrationsFrom(base_path('database/migrations/directory-name'));
in the migration just add $table->index(['column Name 1',''column Name 1']);
With my case, I forgot to do the Laravel migrate before running Infyomlabs to create scaffold!
So one of the reasons for "Undefined index" is that the table is not there yet.
In my laravel app I have set up table for jobs in my database, and setup the .env file with database driver, I run php artisan queue:work in terminal, but nothing gets uploaded when I try to upload it like that, but when I use sync driver everything works fine.
Not sure why is that and how to fix it so that it works with database driver?
I your terminal run the following
php artisan config:clear
php artisan config:cache
Sometimes when a value is changed in your .env file, you might have to run the aove listed commands for them to take effect. It worked for me
To process new jobs you need to run:
php artisan queue:work
in console as mentioned in Queues documentation