Laravel migration works in strange way - mysql

I've dropped my test database then I want to create new database using saved migrations:
2017_03_01_000000_create_api_table.php
2017_03_06_000000_create_beeline_calls.php
2017_03_13_000000_modify_beeline_emails.php
2017_03_14_000000_interactive_forms.php
2017_03_16_000000_model_instances.php
2017_03_24_000000_create_objects.php
2017_03_24_000001_create_objects_tables_v2.php
2017_03_24_000003_make_comments_without_users.php
2017_03_27_000000_add_processed_to_announcements.php
2017_03_29_000000_create_ads_channels.php
2017_03_29_000001_announcement_client.php
2017_04_06_000000_create_filters.php
2017_04_07_000000_create_new_input_types.php
When I run php artisan migrate --pretend
[Doctrine\DBAL\Schema\SchemaException]
There is no column with name 'creator_id' on table 'application_model_instance_announcement_comments'.
But first migration file to run is 2017_03_01_000000_create_api_table.php
Why does it run not from start? Database is empty, migrations table is empty.
As I understand Laravel should run migration files in alphabetical order.

To be able to perform php artisan migrate that table where you are creating the columns can't contain the same column names as in that migration. You must delete it first and with this command
php artisan migrate:refresh
you are doing exactly this
php artisan migrate:rollback
php artisan migrate
There are 2 commands in php artisan migrate:refresh
When changing something in migrations always run these commands:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
composer dump-autoload
It will clear all old stuff and should run smoothly!

Related

switched to mysql from sqlite, unable to migrate databse

I was using sqlite and just tried to connect to my Mysql database by
changing the env.
php artisan migrate:fresh
Nothing Happened
Here's my .env:-
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=white
DB_USERNAME=root
DB_PASSWORD=
I tried deleting the sqlite file and now it shows me this error :- Database (/home/kabir/Desktop/White/database/database.sqlite) does not exist. (SQL: PRAGMA foreign_keys = ON;)
which is normal
Try clearing config and cache files.
In your terminal try
php artisan cache:clear
The solution to this situation is to run these commands:-
php artisan config:clear
php artisan cache:clear

php artisan migrate is not making tables in laravel 7

i am trying to migrate my first migration in laravel 7 project i have created database in phpmyadmin. i have Laragon app for localServer, these are my .env code for database connection
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=portfolio-project
DB_USERNAME=root
DB_PASSWORD=
when i do php artisan migrate it tells me that migrations are migrated, but when i go to phpmyadmin for checking tables it says no tables in this database,
Is there any problem with my phpmyadmin?
O any issue in new version 7 of laravel?
because when i added a phpmyadmin to laragon app there was issue with login password of phpmyadmin,
default password was not working and then i think i edit of its files to make no password at login on phpmyadmin after that i just type root as use and login it works, other old version laravel pakgs are working but this new version of laravel is making this issue at php artisan migrate
Make sure that every time you change your .env file you also do the following commands to clear any cache and make sure you are using the latest changes :
php artisan config:clear
php artisan cache:clear
Also make sure that root has no password and you can login to phpmyadmin without one.
First, close the server and the cmd and start it again then run the following command:
php artisan config:clear
Then run one of these commands:
php artisan migrate:fresh
or
php artisan migrate:refresh
It will drop all tables and recreate them again with the new migrations.
Hope it helps :)

In laravel 5.4 php artisan migrate creating only one table

I created three migrations with php artisan make:migration and after that I ran php artisan migrate. This command creating only one table in my database instead of 3.

Where do I find my table in MySQL after I run a Laravel migration using Homestead?

I am trying to create a "Basic Task List" according to the Laravel documentation. After I run "php artisan migrate", I can see that that my tables were migrated successfully according to the console, which is Git Bash.
In phpmyadmin, the following databases are visible:
homestead
information_schema
mysql
performance_schema
sys
However, I couldn't find my new "tasks" table anywhere in phpmyadmin. Where is my table located in mysql?
It is in the homestead database.
Check your .env and config/database.php files and you'll see how your database is set.

migrating database from development to production - rails

Sorry if the question seems too simple, but I am quite new to rails. I generated scaffold in development mode. Then I migrated the database and it edited the mysql app_development table but not the mysql app_production table . Is there a specific command to migrate it also to the production table ?
If what you're saying is that you didn't use migrations to perform some changes and now rake db:migrate doesn't produce the database structure that you want (obviously, because it has no idea that you made those changes), you still can use the schema.rb.
rake db:schema:dump
Will read the db and generate a schema.rb for it. Then you can load this schema.rb on production with
rake db:schema:load RAILS_ENV=production
Also, you can delete everything and create the database from scratch using the schema.rb file with
rake db:reset RAILS_ENV=production
For window just write
db:migrate
and for Linux sudo rake db:migrate