w1n78

ideas to store record activity logs?

Posted 1 year ago by w1n78

i need to store data whenever a record is created, updated, deleted. my migration file is as follows

Schema::create('record_logs', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')
                ->index()
                ->unsigned();
            $table->string('user_full_name');
            $table->string('user_email');
            $table->bigInteger('record_id')
                ->unsigned();
            $table->string('table_name')
                ->index();
            $table->string('record_action', 50)
                ->comment('created, updated, deleted')
                ->index();
            $table->text('record_before')
                ->nullable();
            $table->text('record_after')
                ->nullable();
            $table->string('environment', 50)
                ->nullable();
            $table->timestamps();
        });

no constraints or cascade actions needed. it just creates records in this table. i may need to query the table and display records that belong to the data being tracked. i'm using mysql database for the project and currently using the same db to store this log table.

should i store it in the same database? keep it in mysql but different database? use sqlite? use redis? i'd love to hear how some of you have this implemented. thanks.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.