Reputation: 7615
I am working on such application where table audit should perform to make revision of updated records. Let's say for example I have to log each field update in Users update.
I wants to create clone of existing user table by
CREATE TABLE users_audit LIKE users;
My main question is, Is there any alternative way or provision in Laravel migration to create table from existing table ?
I know we can run raw sql query in migration up/down method using \DB::raw();
But it would be helpful if any helper function available to create table from existing table like, create or table
Upvotes: 3
Views: 3933
Reputation: 1047
Yes, you can, see the below link
This statement is used to execute raw queries
DB::statement('CREATE TABLE tablename LIKE existingtablename');
Upvotes: 1