Files
mowesta/service-ejb/src/test/sql/prepare_test_database.sql
T
handte a3e213eea2
LocationBasedServices/mowesta/pipeline/head This commit looks good
Add script to prepare test database that can be distributed.
2021-02-05 19:02:03 +01:00

36 lines
2.3 KiB
SQL

###
# This script removes all private data from a mowesta database so that it can be
# distributed to developers for testing. The last few lines are producing a more
# compact version that requires less resources.
#
# @author Marcus
###
# delete all measurement data that is not from handte (about 2-3 minutes)
delete from measurement_data where measurement_id in (select id from measurement where device_id not in (select id from device where user_id in (select id from user where login='handte')));
# delete all measurements that are not from handte (about 1-2 minutes)
delete from measurement where device_id not in (select id from device where user_id in (select id from user where login='handte'));
# delete all devices that are not from handte (seconds)
delete from device where user_id not in (select id from user where login='handte');
# delete all devices without a user, since it seems as if null values are special here (seconds)
delete from device where user_id is null;
# delete the favorites that are not the admin or handte (seconds)
delete from user_location where UserEntity_id not in (select id from user where login in ('handte', 'admin') );
# delete the roles that are not the admin or handte (seconds)
delete from user_role where user_id not in (select id from user where login in ('handte', 'admin') );
# delete all email codes (seconds)
delete from code;
# delete the favorites that are not the admin or handte (seconds)
delete from email where user_id not in (select id from user where login in ('handte', 'admin') );
# delete all users except the admin and handte (seconds)
delete from user where login not in ('handte', 'admin');
# copy the well-known password from handte to admin (seconds)
update user set hash=(select hash from user where login='handte'), iterations=(select iterations from user where login='handte'), salt=(select salt from user where login='handte') where login='admin';
# make the lenovo tablet from handte a device without a user to cover this case (seconds)
update device set user_id=null where id=9934728;
# reduce the amount of data for the compact version (30 seconds, 20 seconds and 17 minutes)
delete from measurement_data where measurement_id in (select id from measurement where time<1604188800000);
delete from measurement where time<1604188800000;
delete from report where time<1604188800000;