Path: blob/main/contrib/kyua/store/migrate_v2_v3.sql
39478 views
-- Copyright 2014 The Kyua Authors.1-- All rights reserved.2--3-- Redistribution and use in source and binary forms, with or without4-- modification, are permitted provided that the following conditions are5-- met:6--7-- * Redistributions of source code must retain the above copyright8-- notice, this list of conditions and the following disclaimer.9-- * Redistributions in binary form must reproduce the above copyright10-- notice, this list of conditions and the following disclaimer in the11-- documentation and/or other materials provided with the distribution.12-- * Neither the name of Google Inc. nor the names of its contributors13-- may be used to endorse or promote products derived from this software14-- without specific prior written permission.15--16-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728-- \file store/v2-to-v3.sql29-- Migration of a database with version 2 of the schema to version 3.30--31-- Version 3 appeared in revision 084d740b1da635946d153475156e335ddfc4aed632-- and its changes were:33--34-- * Removal of historical data.35--36-- Because from v2 to v3 we went from a unified database to many separate37-- databases, this file is parameterized on @ACTION_ID@. The file has to38-- be executed once per action with this string replaced.394041ATTACH DATABASE "@OLD_DATABASE@" AS old_store;424344-- New database already contains a record for v3. Just import older entries.45INSERT INTO metadata SELECT * FROM old_store.metadata;4647INSERT INTO contexts48SELECT cwd49FROM old_store.actions50NATURAL JOIN old_store.contexts51WHERE action_id == @ACTION_ID@;5253INSERT INTO env_vars54SELECT var_name, var_value55FROM old_store.actions56NATURAL JOIN old_store.contexts57NATURAL JOIN old_store.env_vars58WHERE action_id == @ACTION_ID@;5960INSERT INTO metadatas61SELECT metadata_id, property_name, property_value62FROM old_store.metadatas63WHERE metadata_id IN (64SELECT test_programs.metadata_id65FROM old_store.test_programs66WHERE action_id == @ACTION_ID@67) OR metadata_id IN (68SELECT test_cases.metadata_id69FROM old_store.test_programs JOIN old_store.test_cases70ON test_programs.test_program_id == test_cases.test_program_id71WHERE action_id == @ACTION_ID@72);7374INSERT INTO test_programs75SELECT test_program_id, absolute_path, root, relative_path,76test_suite_name, metadata_id, interface77FROM old_store.test_programs78WHERE action_id == @ACTION_ID@;7980INSERT INTO test_cases81SELECT test_cases.test_case_id, test_cases.test_program_id,82test_cases.name, test_cases.metadata_id83FROM old_store.test_cases JOIN old_store.test_programs84ON test_cases.test_program_id == test_programs.test_program_id85WHERE action_id == @ACTION_ID@;8687INSERT INTO test_results88SELECT test_results.test_case_id, test_results.result_type,89test_results.result_reason, test_results.start_time, test_results.end_time90FROM old_store.test_results91JOIN old_store.test_cases92ON test_results.test_case_id == test_cases.test_case_id93JOIN old_store.test_programs94ON test_cases.test_program_id == test_programs.test_program_id95WHERE action_id == @ACTION_ID@;9697INSERT INTO files98SELECT files.file_id, files.contents99FROM old_store.files100JOIN old_store.test_case_files101ON files.file_id == test_case_files.file_id102JOIN old_store.test_cases103ON test_case_files.test_case_id == test_cases.test_case_id104JOIN old_store.test_programs105ON test_cases.test_program_id == test_programs.test_program_id106WHERE action_id == @ACTION_ID@;107108INSERT INTO test_case_files109SELECT test_case_files.test_case_id, test_case_files.file_name,110test_case_files.file_id111FROM old_store.test_case_files112JOIN old_store.test_cases113ON test_case_files.test_case_id == test_cases.test_case_id114JOIN old_store.test_programs115ON test_cases.test_program_id == test_programs.test_program_id116WHERE action_id == @ACTION_ID@;117118119DETACH DATABASE old_store;120121122