Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- marek@debian9:~/dbs_restruct$ cat import.sh
- #!/bin/bash
- username="supertajne_meno"
- password="supertajne_heslo"
- host="fixer-srv1"
- mysql -u $username -p$password fixer_live -h $host < 0_import.sql
- marek@debian9:~/dbs_restruct$ cat 0_import.sql
- use fixer_live;
- set sql_safe_updates=0;
- -- create temporary column for convertion
- alter table log_marker_positions add tmp BIGINT not null;
- alter table log_board_positions add tmp BIGINT not null;
- alter table log_ewma_positions add tmp BIGINT not null;
- -- make conversion
- update log_marker_positions set tmp = unix_timestamp(created) * 1000;
- update log_board_positions set tmp = unix_timestamp(created) * 1000;
- update log_ewma_positions set tmp = unix_timestamp(created) * 1000;
- -- modify created column type
- alter table log_marker_positions modify created BIGINT not null;
- alter table log_board_positions modify created BIGINT not null;
- alter table log_ewma_positions modify created BIGINT not null;
- -- update created column with correct value
- update log_marker_positions set created = tmp;
- update log_board_positions set created = tmp;
- update log_ewma_positions set created = tmp;
- -- remove temporary column
- alter table log_marker_positions drop column tmp;
- alter table log_board_positions drop column tmp;
- alter table log_ewma_positions drop column tmp;
- marek@debian9:~/dbs_restruct$ ./import.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement