Skip to content
Snippets Groups Projects
Select Git revision
  • d8442a94e74a04e28183cb2cc01d7daa2af9b3d2
  • main default protected
  • dev
  • f-unmod
  • f-checkidentical
  • f-simple-breakpoint
  • f-new-debug-tree
  • f-existing-file-id
  • f-no-ident
  • f-collect-problems
  • f-refactor-debug-tree
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.1
  • v0.10.0
  • v0.9.1
  • v0.9.0
  • v0.8.0
  • v0.7.1
  • v0.7.0
  • v0.6.0
  • v0.5.0
  • v0.4.0
  • v0.3.0
  • v0.2.0
  • v0.1.0
27 results

test_dataset_crawler.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    patch.sh 2.60 KiB
    #!/bin/bash
    #
    # ** header v3.0
    # This file is a part of the CaosDB Project.
    #
    # Copyright (C) 2018 Research Group Biomedical Physics,
    # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
    #
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU Affero General Public License as
    # published by the Free Software Foundation, either version 3 of the
    # License, or (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU Affero General Public License for more details.
    #
    # You should have received a copy of the GNU Affero General Public License
    # along with this program. If not, see <https://www.gnu.org/licenses/>.
    #
    # ** end header
    #
    # implements new datetime data model
    # Update mysql schema to version v2.0.16
    NEW_VERSION="v2.0.16"
    OLD_VERSION="v2.0.15"
    
    if [ -z "$UTILSPATH" ]; then
     UTILSPATH="../utils"
    fi
    
    . $UTILSPATH/patch_header.sh $*
    
    ADD_SECONDS_COLUMN='ALTER TABLE transaction_log ADD COLUMN seconds BIGINT UNSIGNED NOT NULL DEFAULT 0;'
    ADD_NANOS_COLUMN='ALTER TABLE transaction_log ADD COLUMN nanos INT UNSIGNED NOT NULL DEFAULT 0;'
    DELETE_OLD_COLUMNS='ALTER TABLE transaction_log DROP COLUMN date; ALTER TABLE transaction_log DROP COLUMN time; ALTER TABLE transaction_log DROP COLUMN ns;'
    DELETE_USER_ID_COLUMN='ALTER TABLE transaction_log DROP COLUMN user_id;'
    
    function convert_datetime_to_secs {
        leap_secs=('1972-06-30' '1972-12-31' '1973-12-31' '1974-12-31' '1975-12-31' '1976-12-31' '1977-12-31' '1978-12-31' '1979-12-31' '1981-06-30' '1982-06-30' '1983-06-30' '1985-06-30' '1987-12-31' '1989-12-31' '1990-12-31' '1992-06-30' '1993-06-30' '1994-06-30' '1995-12-31' '1997-06-30' '1998-12-31' '2005-12-31' '2008-12-31' '2012-06-30' '2015-06-30', '2016-12-31')
    	
    	# update seconds table
    	mysql_execute 'UPDATE transaction_log set seconds = unix_timestamp(CONCAT(date(date), " ",  time(time-1-100-10000)));'
    
    	# remove extra nanosecond
    	mysql_execute 'UPDATE transaction_log set nanos = ns-1 WHERE ns > 0;'
    
        # add leap second correction
        for l in "${leap_secs[@]}"; do
            mysql_execute "UPDATE transaction_log SET seconds=seconds+1 WHERE seconds>unix_timestamp('$l 23:59:59');"
        done
    }
    
    
    check_version $OLD_VERSION
    
    dump_table 'transaction_log'
    
    mysql_execute "$ADD_SECONDS_COLUMN"
    mysql_execute "$ADD_NANOS_COLUMN"
    
    convert_datetime_to_secs
    
    # clean up
    mysql_execute "$DELETE_OLD_COLUMNS"
    TRY=$(mysql_execute "$DELETE_USER_ID_COLUMN" 2>&1)
    
    update_version $NEW_VERSION
    
    success