0

I am creating a system that has two interfaces, the admin and the landing page. In my landing page, the user can see the blogs, news that being added by the admin in the database. My problem is that I have another database that have already tables and values and i want to connect it. Should i migrate it or i will import it directly? If i migrate it how can i retain the values? Please help for my homework.

my default .env file


APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:HoQcNyCc5KEGw4yjqpBIdKzTC+yeDoOJcerVMEVx+fs=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=adminpanel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
`


draw134
  • 1,053
  • 4
  • 35
  • 84
  • 1
    Possible duplicate of [How to use multiple databases in Laravel](https://stackoverflow.com/questions/31847054/how-to-use-multiple-databases-in-laravel) – Phiter Jun 19 '19 at 02:27
  • it shows me an error 'database [mysql2] not configured' – draw134 Jun 19 '19 at 02:37
  • Well you should follow everything in the best answer. You need to set up config/database.php – Phiter Jun 19 '19 at 02:48
  • sorry sir my mistake i didint rename the connection to mysql2 in my env file. now its solved. thanks – draw134 Jun 19 '19 at 02:51

1 Answers1

0

In Laravel, you're able to keep two connections or migrate the data. The biggest question here is if worth migrates data to a new database.

For responding to this question I'd like to consider some points:

Do you will need to change the legacy structure?

If you responded yes, maybe it worth you migrate the structure to Laravel schema and then, restore the data in this new database.

In this case, I recommend you use a tool like mysql dump to extract the data.

Do you will have to only consume the data without change it or save new? In this case, I recommend you to create a new Laravel connection and consume this data. Look at here

I hope that I could help you. :)