Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete old entries with a .bat file (wamp Mysql+windows) #1210

Open
onetic opened this issue Sep 25, 2018 · 0 comments
Open

Delete old entries with a .bat file (wamp Mysql+windows) #1210

onetic opened this issue Sep 25, 2018 · 0 comments

Comments

@onetic
Copy link

onetic commented Sep 25, 2018

Hello,
i have installed traccar 3.9 + webui on a 2012 microsoft windows server.
i have created a batch file that run1 sql script to delete old entries older than 2 months.
My batch execute "mysql -uroot -pmypassword traccar < C:\wamp64\bin\mysql\mysql5.7.14\bin\purge2months.sql

The purge2months.sql contains :
alter table events DROP FOREIGN KEY events_fkey_position_id;
alter table events ADD CONSTRAINT events_fkey_position_id FOREIGN KEY (position_id) REFERENCES positions (id) ON DELETE CASCADE;
UPDATE devices SET latestPosition_id = NULL WHERE latestPosition_id IN (SELECT id FROM positions WHERE time < DATE_ADD(NOW(), INTERVAL -2 MONTH));
DELETE FROM events WHERE time < DATE_ADD(NOW(), INTERVAL -2 MONTH);
DELETE FROM positions WHERE time < DATE_ADD(NOW(), INTERVAL -2 MONTH);

Do you think my "purge2months.sql" is ok?

@onetic onetic changed the title backup and delete old entries with a .bat file (wamp Mysql+windows) Delete old entries with a .bat file (wamp Mysql+windows) Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant