Moving MySQL Record To Other Table After Timeframe
I am trying to find the best way to process a record with a timestamp field whereby it would automatically move from one table to another table after 30 minutes.
If you are using
MySQL 5.1.6 and later, check out MySQL events.
Events work the same with other routines, you can
ALTER, and even
Martin Psinas has basic examples of this. (Just found online, we're not friends, lol)
First, you'll have to enable events scheduler:
SET GLOBAL event_scheduler = ON;
Then, you can create your event like (base from your question):
CREATE EVENT ProcessRecord ON SCHEDULE EVERY 30 MINUTE --STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY --ENDS CURRENT_TIMESTAMP + INTERVAL 1 YEAR DO BEGIN INSERT INTO ... SELECT ... END
Otherwise, you can go with windows scheduled tasks, if you're using windows platform.
- → I can't do a foreign key, constraint error
- → How to implement DbDongle::convertTimestamps as workaround of invalid timestamps with MySql strict
- → MySQL error "Foreign key constraint is incorrectly formed"
- → Eloquent Multitable query
- → "Laravel 5.1" add user and project with userId
- → Database backup with custom code in laravel 5 and get the data upto 10 rows from per table in database
- → Laravel 5.1 QueryException when trying to delete a project
- → Using Array in '->where()' for Laravel Query Building
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Laravel Eloquent Joining Strange query
- → convert time using mysql laravel 5
- → How to update a column after an expiration date in MySQL?
- → Foreign key constraint fails on existing key