Closed ramzdam closed 5 years ago
Hi @ramzdam,
The provision destroy the database so you cannot do this in 2 steps with a vagrant reload. To get through this I created extra script to customise the setup. I give you here the steps to import a db from existing project in your vagrant provision.
First ou have to dump the db of your project.
mysqldump -u user -p database | gzip > db-dump-latest.sql.gz
You'll need your crypted key under app/etc/env.php from your existing project:
'crypt' =>
array (
'key' => '***************************',
)
Put your dump in extra directory.
Create extra/100-pre-build.sh sequence and add this script to import your dump:
#!/bin/bash
if [ $PROJECT_SOURCE == "composer" ]; then exit 0; fi
if [ -f /home/vagrant/extra/db-dump-latest.sql.gz ]; then gunzip /home/vagrant/extra/db-dump-latest.sql.gz fi if [ -f /home/vagrant/extra/db-dump-latest.sql ]; then echo '--- Magento db dump import ---' mysql -u vagrant -pvagrant -e "USE ${PROJECT_NAME};SET FOREIGN_KEY_CHECKS = 0;source /home/vagrant/extra/db-dump-latest.sql;SET FOREIGN_KEY_CHECKS = 1;" mysql -u vagrant -pvagrant -e "USE ${PROJECT_NAME};SET FOREIGN_KEY_CHECKS = 0;TRUNCATE TABLE admin_passwords;TRUNCATE TABLE admin_user;SET FOREIGN_KEY_CHECKS = 1;" fi
5. Create extra/120-post-build.sh and add this script with your crypted key:
if [ $PROJECT_SOURCE == "composer" ]; then exit 0; fi
sudo -u "$PROJECT_SETUP_OWNER" bin/magento setup:config:set -n --key "put here the value of your crypted key"
6. Once it's done you just have to add this in your Vagrantfile in order to upload the dump to guest machine.
... process_extra_file(config, 'extra/db-dump-latest.sql.gz') ...
7. Run vagrant provision and everything should work.
Hope this help.
And then, in order to do your migration it's development time.
You can change the version of Magento in composer.json to 2.3.1 Then you can work under vagrant and run those commands: composer update magento setup:upgrade magento setup:di:compile
The compile should crash and you'll have to fix your code until it work.
This way you can achieve your migration from 2.1 to 2.3
And then, in order to do your migration it's development time.
You can change the version of Magento in composer.json to 2.3.1 Then you can work under vagrant and run this commands: composer update magento setup:upgrade magento setup:di:compile
The compile should crash and you'll have to fix your code until it work.
This way you can achieve your migration from 2.1 to 2.3
What you mean by this? Sorry but I set the magento on my yaml file as 2.3.1..
The version of Magento in config.yaml is only used when you setup Magento as a clean state from composer, in your case you try to install it from an existing project with git. The version used will be based from your existing project not from config.yaml
I see I understand now. Will try your solution and will give feedback for this. Thanks a lot for the prompt reply.
You have two way in order to achieve your migration:
So you can go from 2.2.1 to 2.3.1 or you can start with 2.3.1 and migrate your code. Don't know which one is the best in your case, the second way is a bit cheaty but easier.
Actually our project is already 2.3.1 so I don't need to do any of those stuff right? I just need to run vagrant up
and everything will be fine? Since in our composer it's also defined as 2.3.1 for the version
Sorry I mixed up with an other issue about migration .. I'm a bit confused. My bad, stay on my first answer!
Wow @zepgram your solution really works... Thanks a million dude. Hope this solution will be included in your future version. Really helpful for those having a dump and an existing project. Kudos to you dude
Hi @zepgram I installed this project and set it up with an existing project from my repo. Now this project is already working. Now I redownloaded your project and reinstalled the magento 2.3.1 version. At first it gave me an error saying
Cannot find magento.store_website
which I think is just correct? Since I'm loading an existing project and the Magento DB is not created since I didn't go to the whole db/website installation process. So I uploaded my own DB dump from the created MariaDB connection. Now I did a vagrant reload --provision then visited the Admin. Upon visiting it I got an error saying the website is in Maintenance mode so I runbin/magento maintenance:disable
then revisit the site again. Now it says the Application is not installed. So whenever I visit the site it redirects me to theSetup Page
. Any idea regarding this?Edit: Upon digging some more it seems that even if I set my config.yaml to pull from existing project it's trying to install Magento as a clean state? It's installing the database schema for the installation of installDataFixtures. And since it's installing from existing project there are no Database when doing vagrant reload --provision since somehow the database and all tables are being deleted. Now when I manually upload the DB dump and access the db that's when I get the mode is set to maintenance mode (which is why I needed to disable it every now and then). Below is the scripts that causes the issue
FIle: approot/setup/src/Magento/Setup/Model/Installer.php Line: 328 Function:
Is this the correct process? Doing a DB dump? or probably offer the script to upload an existing DB dump perhaps? so that if the installer check for the dump it won't fail this there are already an existing db.
Or maybe you have a solution for my issue? Would really appreciate your help on this