laravel - mysql - how to migrate tables - mysql

my problem ... i can't migrate from mysql to laravel
i am working on MySQL database and i have a lot of tables i tried to migrate those table to laravel but it doesn't work
my steps was like that:
1-create the table in mysql database
2-opened laravel and write in the .env file the database credentials then i write .. php artisan migrate in the cmd
it says nothing to migrate
all i want is to have the same tables in mysql database to be in my laravel project

There is migrations table in your database which contains the names of the migrations that were already run and exist. So what you need is just to create the database with no tables in it, create your migrations and run php artisan migrate this will run all of your migration files and will create the tables for you.

Related

migrate form my sql to postgres then keep updating

right now am using pgloader to migrate a MySQL database to a PostgreSQL DB.
The migration working fine but the issue that I want to update my Postgres DB after the migration from MySQL, is that possible?
right now every time I migrate it delete the previous data then create it again with the latest data from MySQL.

Use MySQL workbench to create tables and data for rails app

Can I use MySQL Workbench to create the tables and add data then import / connect that into my Rails app? My Rails app is already connected to MySQL. I am just wondering if I create tables in MySQL Workbench through the app_development schema if that will sync over to my Rails project or not and if there's a way to check to see if it worked?
You can use
rake db:schema:dump
to generate schema.rb from an existing database.
Having schema.rb, you can generate an empty initial migration and put create_table and other statements from generated schema there. Doing this will allow you to use all the relevant rake tasks just as if you developed your database "the Rails way" — via a series of migrations.

Laravel artisan migrate

I'm working on a site with the latest version of laravel, and we have recently changed the MySQL DB location from a remote host to a local host. After moving and editing the config/database.php file to reflect the changes, I tried to run the command php artisan migrate, but I'm not getting anything back.
There is no response on the terminal, and no results in the new database. I've also tried migrate:refresh and migrate:status.
How do I re-run the migrations and get the tables in the new database?
At first drop your database table or tables and than execute
php artisan migrate:refresh
hopefully it'll work for you
You can just export DB to a file and import it on a local host. You do not need to run php artisan migrate command.
You do not want to run migrations if you already have DB with tables and data.

how to create migration for already exist table in rails

I have deleted the migration files in rails project. Now i want run the rails project in another system for that i need the migration files to create the table. please tell me how to create the migration files for already created tables in rails.
You still have db/schema.rb file containing all tables and their details..you can use it by rake db:schema:load,this will load the schema into the database, which is faster than running all the migrations.
NEVER DELETE YOUR MIGRATION AND MAINTAIN IT IN SUBVERSION/GIT

How to restore database tables from MySQL Database

hi everybody i'm new to Ruby on Rails...
I created a Rails Application for that i created a database called 'cart' in MySQL database by using rake command. but unfortunately my database got crashed. right now there are no databases including older ones also deleted.
please help me, how can i get my all databases from MySQL s/w. is there any command to restore the crashed data.
Thanks
If you don't have backup it could be hard. You can remove database, create another and rake db:migrate but it will only create a structure for you and will not restore data.
You can try to reproduce your records from rails logs but it will be a lot of work
What do you mean by database crashed?