3

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

3
  • maybe you wanna have a look at this github.com/Xethron/migrations-generator Commented Dec 8, 2017 at 5:12
  • yes, @usrNotFound we can use but for just one table I won't interested to add whole library Commented Dec 8, 2017 at 5:27
  • you can use php artisan migrate:generate table1,table2,table3,table4,table5 as many tables as you want Commented Dec 8, 2017 at 5:28

1 Answer 1

1

Yes, you can, see the below link

Click this link

This statement is used to execute raw queries

DB::statement('CREATE TABLE tablename LIKE existingtablename');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.