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.
Related
I want to host a django project on heroku. Locally, I developed it using MySQL database. And I have also pushed it to heroku but I get an Error message whenever I run heroku open command on command prompt. The error message is Can't connect to local MySQL server through socket. Though I'm a newbie in using databases, the way I understand the error is that heroku can't connect to local MySQL server which I'm using for local development. I don't want to connect to a remote MySQL database, instead, I want to connect to Postgre database just as heroku recommended.
Being a newbie in the use of database, I don't know the best way to migrate to Postgre or how to add MySQL in my project to .gitignore. Is it possible for me to start running Postgre on heroku while MySQL isn't added to . gitignore and is still the database in settings.py? Must I clear MySQL database or add it to gitignore before I can use Postgre?
PostgreSQL settings for Heroku:
Please install dj_database_url using below command:
pip install dj-database-url
In settings.py , import dj_database_url and add below settings at the end of the file:
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
Done !! Now, deploy again to Heroku.
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.
I am wondering why I can't run php artisan commands on my recently cloned laravel project. I get an error SQLSTATE[42S02]: Base table or view not found:. I don't get why this is occurring, as I'm trying to run php artisan migrate after having created the database on this machine. Of course the base table or view is not found... Why would this happen and how can I solve the problem?
I'm working on changing my environment from vagrant to docker and I came across one hitch. With vagrant I have a bash file that will pull data from ftp and restore it in my local so that I can work with the most up to date data.
This is my code
php artisan db:restore --database=mysql --source=ftp --sourcePath=$(date +'%Y')"/"$(date +'%m')"/"$(date +%m-%d-%Y -d "yesterday")".gz" --compression=gzip
php artisan migrate
Inside of my work container I run this and it wont find the mysql command because mysql is in a different container. What can I do to fix my work flow?
This answer is about rails migrations, but you could take a similar approach to laravel. Create a container that has the required laravel tools and required MySQL tools (likely this) to connect to the database.
You could then combine it with a suggestion in this answer and create a migration script that you can add to your image. As larsks points out in the comments, it would allow you to encapsulate the logic for where to get the backup data and how to restore it in one place. Assuming you named this script restore, you could run your restore command like this
docker run myimage restore
I'm working in a project synchronized with a remote repository. I execute this command to update the database on my localhost (development environment):
php app/console doctrine:schema:update --force
but I've read on Doctrine documentation that it shouldn't be executed on a production environment, so I have to execute now the SQL command directly on my production database.
The problem is that I'm not sure what columns I've changed, so I'm looking for a way to know the differences between those databases. Any idea?
Better is use DB versioning system (doctrine/doctrine-migrations-bundle)
Another way - make full db dump to dev environment than make
php app/console doctrine:schema:update --dump-sql
And start queries on live