Can I import a mysql dump to a laravel migration?

后端 未结 10 2004
离开以前
离开以前 2020-12-24 11:46

I have a complete database and need to create migration. I guess there must be a way to do it from a dump but not sure. Is there any way automatically or at least easier to

10条回答
  •  情歌与酒
    2020-12-24 12:26

    You can import dumps in Laravel like this:

    DB::unprepared(file_get_contents('full/path/to/dump.sql'));
    

    If I were to refactor an existing app, though, I'd take the time to write migrations from scratch, import the dump into different tables (or a different db, if table names are the same) then import the content to the new structure via seeds.

提交回复
热议问题