Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 0ea94e9

Browse files
committed
Add undo migration scripts for the dummy test data
1 parent 54141bf commit 0ea94e9

25 files changed

+515
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DELETE FROM pedigree_edge where this_node_id IN ('pedigree1', 'pedigree2', 'pedigree3');
2+
DELETE FROM pedigree_node where id in ('pedigree1', 'pedigree2', 'pedigree3');
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
UPDATE cross_entity SET planned_cross_id = null WHERE id = 'cross3';
2+
DELETE FROM cross_entity_external_references where cross_entity_id = 'cross4';
3+
DELETE FROM external_reference where id = 'cross_er_4';
4+
DELETE FROM cross_parent where cross_id = 'cross4';
5+
DELETE FROM cross_pollination_event where cross_id = 'cross4';
6+
DELETE FROM cross_entity where id = 'cross4';
7+
8+
UPDATE seed_lot_content_mixture SET cross_id = null where id = 'seed_lot_content_mixture3';
9+
DELETE FROM cross_entity_external_references where cross_entity_id = 'cross3';
10+
DELETE FROM external_reference where id = 'cross_er_3';
11+
DELETE FROM cross_parent where cross_id = 'cross3';
12+
DELETE FROM cross_pollination_event where cross_id = 'cross3';
13+
DELETE FROM cross_entity_cross_attributes where cross_entity_id = 'cross3';
14+
DELETE FROM cross_entity where id = 'cross3';
15+
16+
DELETE FROM crossing_project_external_references where crossing_project_entity_id = 'crossing_project2';
17+
DELETE FROM external_reference where id = 'crossing_project_er_2';
18+
DELETE FROM crossing_project where id = 'crossing_project2';
19+
20+
UPDATE observation_unit SET cross_id = null where id = 'observation_unit3';
21+
UPDATE cross_entity SET planned_cross_id = null WHERE id = 'cross1';
22+
DELETE FROM cross_entity_external_references where cross_entity_id = 'cross2';
23+
DELETE FROM external_reference where id = 'cross_er_2';
24+
DELETE FROM cross_parent where cross_id = 'cross2';
25+
DELETE FROM cross_pollination_event where cross_id = 'cross2';
26+
DELETE FROM cross_entity where id = 'cross2';
27+
28+
UPDATE observation_unit SET cross_id = null where id IN ('observation_unit2', 'observation_unit1');
29+
UPDATE seed_lot_content_mixture SET cross_id = null where id in ('seed_lot_content_mixture1', 'seed_lot_content_mixture2');
30+
DELETE FROM cross_entity_external_references where cross_entity_id = 'cross1';
31+
DELETE FROM external_reference where id = 'cross_er_1';
32+
DELETE FROM cross_parent where cross_id = 'cross1';
33+
DELETE FROM cross_pollination_event where cross_id = 'cross1';
34+
DELETE FROM cross_entity_cross_attributes where cross_entity_id = 'cross1';
35+
DELETE FROM cross_entity where id = 'cross1';
36+
37+
DELETE FROM crossing_project_external_references where crossing_project_entity_id = 'crossing_project1';
38+
DELETE FROM external_reference where id = 'crossing_project_er_1';
39+
DELETE FROM crossing_project where id = 'crossing_project1';
40+
41+
-- crossing project 1
42+
INSERT INTO crossing_project (auth_user_id, id, description, "name", program_id) VALUES('anonymousUser', 'crossing_project1', 'This is a crossing project', 'Crossing Project', 'program1');
43+
INSERT INTO external_reference(id, external_reference_id, external_reference_source) VALUES ('crossing_project_er_1', 'https://brapi.org/specification', 'BrAPI Doc');
44+
INSERT INTO crossing_project_external_references(crossing_project_entity_id, external_references_id) VALUES ('crossing_project1', 'crossing_project_er_1');
45+
46+
INSERT INTO cross_entity (auth_user_id, id, cross_type, "name", planned, crossing_project_id) VALUES('anonymousUser', 'cross1', 0, 'germ1 X germ2', false, 'crossing_project1');
47+
INSERT INTO cross_entity_cross_attributes (cross_entity_id, cross_attributes) VALUES('cross1', 'maleFloweringDate:2020-04-01');
48+
insert into cross_pollination_event (id, pollination_number, pollination_successful, pollination_time_stamp, cross_id) values ('cross_pollination_event1', 'PN123', true, '2020-04-08', 'cross1');
49+
INSERT INTO cross_parent (id, parent_type, cross_id, crossing_project_id, germplasm_id, observation_unit_id) VALUES('cross_parent1', 0, 'cross1', 'crossing_project1', 'germplasm1', 'observation_unit1');
50+
INSERT INTO cross_parent (id, parent_type, cross_id, crossing_project_id, germplasm_id, observation_unit_id) VALUES('cross_parent2', 1, 'cross1', 'crossing_project1', 'germplasm2', 'observation_unit2');
51+
INSERT INTO external_reference(id, external_reference_id, external_reference_source) VALUES ('cross_er_1', 'https://brapi.org/specification', 'BrAPI Doc');
52+
INSERT INTO cross_entity_external_references(cross_entity_id, external_references_id) VALUES ('cross1', 'cross_er_1');
53+
UPDATE seed_lot_content_mixture SET cross_id = 'cross1' where id = 'seed_lot_content_mixture1';
54+
UPDATE seed_lot_content_mixture SET cross_id = 'cross1' where id = 'seed_lot_content_mixture2';
55+
UPDATE observation_unit SET cross_id = 'cross1' where id = 'observation_unit1';
56+
UPDATE observation_unit SET cross_id = 'cross1' where id = 'observation_unit2';
57+
58+
INSERT INTO cross_entity (auth_user_id, id, cross_type, "name", planned, crossing_project_id, status) VALUES('anonymousUser', 'cross2', 0, 'germ2 X germ3', true, 'crossing_project1', 1);
59+
insert into cross_pollination_event (id, pollination_number, pollination_successful, pollination_time_stamp, cross_id) values ('cross_pollination_event2', 'PN234', true, '2020-05-09', 'cross2');
60+
insert into cross_pollination_event (id, pollination_number, pollination_successful, pollination_time_stamp, cross_id) values ('cross_pollination_event4', 'PN456', false, '2020-04-09', 'cross2');
61+
INSERT INTO cross_parent (id, parent_type, cross_id, crossing_project_id, germplasm_id, observation_unit_id) VALUES('cross_parent3', 0, 'cross2', 'crossing_project1', 'germplasm3', 'observation_unit3');
62+
INSERT INTO cross_parent (id, parent_type, cross_id, crossing_project_id, germplasm_id, observation_unit_id) VALUES('cross_parent4', 1, 'cross2', 'crossing_project1', 'germplasm2', 'observation_unit2');
63+
INSERT INTO external_reference(id, external_reference_id, external_reference_source) VALUES ('cross_er_2', 'https://brapi.org/specification', 'BrAPI Doc');
64+
INSERT INTO cross_entity_external_references(cross_entity_id, external_references_id) VALUES ('cross2', 'cross_er_2');
65+
UPDATE cross_entity SET planned_cross_id = 'cross2' WHERE id = 'cross1';
66+
UPDATE observation_unit SET cross_id = 'cross2' where id = 'observation_unit3';
67+
68+
69+
-- crossing project 2
70+
INSERT INTO crossing_project (auth_user_id, id, description, "name", program_id) VALUES('anonymousUser', 'crossing_project2', 'This is a crossing project', 'Crossing Project', 'program2');
71+
INSERT INTO external_reference(id, external_reference_id, external_reference_source) VALUES ('crossing_project_er_2', 'https://brapi.org/specification', 'BrAPI Doc');
72+
INSERT INTO crossing_project_external_references(crossing_project_entity_id, external_references_id) VALUES ('crossing_project2', 'crossing_project_er_2');
73+
74+
INSERT INTO cross_entity (auth_user_id, id, cross_type, "name", planned, crossing_project_id) VALUES('anonymousUser', 'cross3', 0, 'germ1 X germ2', false, 'crossing_project2');
75+
INSERT INTO cross_entity_cross_attributes (cross_entity_id, cross_attributes) VALUES('cross3', 'maleFloweringDate:2020-04-03');
76+
insert into cross_pollination_event (id, pollination_number, pollination_successful, pollination_time_stamp, cross_id) values ('cross_pollination_event3', 'PN345', true, '2020-04-08', 'cross3');
77+
INSERT INTO cross_parent (id, parent_type, cross_id, crossing_project_id, germplasm_id, observation_unit_id) VALUES('cross_parent5', 0, 'cross3', 'crossing_project2', 'germplasm1', 'observation_unit1');
78+
INSERT INTO cross_parent (id, parent_type, cross_id, crossing_project_id, germplasm_id, observation_unit_id) VALUES('cross_parent6', 1, 'cross3', 'crossing_project2', 'germplasm2', 'observation_unit2');
79+
INSERT INTO external_reference(id, external_reference_id, external_reference_source) VALUES ('cross_er_3', 'https://brapi.org/specification', 'BrAPI Doc');
80+
INSERT INTO cross_entity_external_references(cross_entity_id, external_references_id) VALUES ('cross3', 'cross_er_3');
81+
UPDATE seed_lot_content_mixture SET cross_id = 'cross3' where id = 'seed_lot_content_mixture3';
82+
83+
INSERT INTO cross_entity (auth_user_id, id, cross_type, "name", planned, crossing_project_id, status) VALUES('anonymousUser', 'cross4', 0, 'germ2 X germ3', true, 'crossing_project2', 0);
84+
insert into cross_pollination_event (id, pollination_number, pollination_successful, pollination_time_stamp, cross_id) values ('cross_pollination_event5', 'PN567', true, '2020-05-09', 'cross4');
85+
insert into cross_pollination_event (id, pollination_number, pollination_successful, pollination_time_stamp, cross_id) values ('cross_pollination_event6', 'PN678', false, '2020-04-09', 'cross4');
86+
INSERT INTO cross_parent (id, parent_type, cross_id, crossing_project_id, germplasm_id, observation_unit_id) VALUES('cross_parent7', 0, 'cross4', 'crossing_project2', 'germplasm3', 'observation_unit3');
87+
INSERT INTO cross_parent (id, parent_type, cross_id, crossing_project_id, germplasm_id, observation_unit_id) VALUES('cross_parent8', 1, 'cross4', 'crossing_project2', 'germplasm2', 'observation_unit2');
88+
INSERT INTO external_reference(id, external_reference_id, external_reference_source) VALUES ('cross_er_4', 'https://brapi.org/specification', 'BrAPI Doc');
89+
INSERT INTO cross_entity_external_references(cross_entity_id, external_references_id) VALUES ('cross4', 'cross_er_4');
90+
UPDATE cross_entity SET planned_cross_id = 'cross4' WHERE id = 'cross3';
91+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
DELETE FROM observation_unit_external_references where observation_unit_entity_id = 'observation_unit3';
2+
DELETE FROM external_reference where id = 'observation_unit_er_3';
3+
DELETE FROM observation_unit_level where position_id = 'observation_unit_position3';
4+
DELETE FROM observation_unit_position where id = 'observation_unit_position3';
5+
DELETE FROM coordinate where id = 'observation_unit_coor_3';
6+
DELETE FROM geojson where id = 'observation_unit_geo_3';
7+
DELETE FROM observation_unit_treatment where observation_unit_id = 'observation_unit3';
8+
DELETE FROM observation_unit where id = 'observation_unit3';
9+
10+
DELETE FROM observation_unit_external_references where observation_unit_entity_id = 'observation_unit2';
11+
DELETE FROM external_reference where id = 'observation_unit_er_2';
12+
DELETE FROM observation_unit_level where position_id = 'observation_unit_position2';
13+
DELETE FROM observation_unit_position where id = 'observation_unit_position2';
14+
DELETE FROM coordinate where id = 'observation_unit_coor_2';
15+
DELETE FROM geojson where id = 'observation_unit_geo_2';
16+
DELETE FROM observation_unit_treatment where observation_unit_id = 'observation_unit2';
17+
DELETE FROM observation_unit where id = 'observation_unit2';
18+
19+
DELETE FROM observation_unit_external_references where observation_unit_entity_id = 'observation_unit1';
20+
DELETE FROM external_reference where id = 'observation_unit_er_1';
21+
DELETE FROM observation_unit_level where position_id = 'observation_unit_position1';
22+
DELETE FROM observation_unit_position where id = 'observation_unit_position1';
23+
DELETE FROM coordinate where id = 'observation_unit_coor_1';
24+
DELETE FROM geojson where id = 'observation_unit_geo_1';
25+
DELETE FROM observation_unit_treatment where observation_unit_id = 'observation_unit1';
26+
DELETE FROM observation_unit where id = 'observation_unit1';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
DELETE FROM seed_lot_transaction_external_references where seed_lot_transaction_entity_id = 'seed_lot_transaction2';
2+
DELETE FROM external_reference where id = 'seed_lot_transaction_er_2';
3+
DELETE FROM seed_lot_transaction where id = 'seed_lot_transaction2';
4+
5+
DELETE FROM seed_lot_transaction_external_references where seed_lot_transaction_entity_id = 'seed_lot_transaction1';
6+
DELETE FROM external_reference where id = 'seed_lot_transaction_er_1';
7+
DELETE FROM seed_lot_transaction where id = 'seed_lot_transaction1';
8+
9+
DELETE FROM seed_lot_external_references where seed_lot_entity_id = 'seed_lot2';
10+
DELETE FROM external_reference where id = 'seed_lot_er_2';
11+
DELETE FROM seed_lot_content_mixture where seed_lot_id = 'seed_lot2';
12+
DELETE FROM seed_lot where id = 'seed_lot2';
13+
14+
DELETE FROM seed_lot_external_references where seed_lot_entity_id = 'seed_lot1';
15+
DELETE FROM external_reference where id = 'seed_lot_er_1';
16+
DELETE FROM seed_lot_content_mixture where seed_lot_id = 'seed_lot1';
17+
DELETE FROM seed_lot where id = 'seed_lot1';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DELETE FROM germplasm_attribute_value_external_references where germplasm_attribute_value_entity_id = 'attribute_val3';
2+
DELETE FROM external_reference where id = 'attribute_val_er_3';
3+
DELETE FROM germplasm_attribute_value where id = 'attribute_val3';
4+
5+
DELETE FROM germplasm_attribute_value_external_references where germplasm_attribute_value_entity_id = 'attribute_val2';
6+
DELETE FROM external_reference where id = 'attribute_val_er_2';
7+
DELETE FROM germplasm_attribute_value where id = 'attribute_val2';
8+
9+
DELETE FROM germplasm_attribute_value_external_references where germplasm_attribute_value_entity_id = 'attribute_val1';
10+
DELETE FROM external_reference where id = 'attribute_val_er_1';
11+
DELETE FROM germplasm_attribute_value where id = 'attribute_val1';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
DELETE FROM variable_base_entity_external_references WHERE variable_base_entity_id = 'attribute2';
2+
DELETE FROM external_reference where id = 'attribute_er_2';
3+
DELETE FROM variable_base_entity_synonyms where variable_base_entity_id = 'attribute2';
4+
DELETE FROM variable_base_entity_context_of_use where variable_base_entity_id = 'attribute2';
5+
DELETE FROM germplasm_attribute_definition where id = 'attribute2';
6+
DELETE FROM trait where id = 'trait_attribute2';
7+
DELETE FROM method where id = 'method_attribute2';
8+
DELETE FROM scale where id = 'scale_attribute2';
9+
10+
DELETE FROM variable_base_entity_external_references WHERE variable_base_entity_id = 'attribute1';
11+
DELETE FROM external_reference where id = 'attribute_er_1';
12+
DELETE FROM variable_base_entity_synonyms where variable_base_entity_id = 'attribute1';
13+
DELETE FROM variable_base_entity_context_of_use where variable_base_entity_id = 'attribute1';
14+
DELETE FROM germplasm_attribute_definition where id = 'attribute1';
15+
DELETE FROM trait where id = 'trait_attribute1';
16+
DELETE FROM method where id = 'method_attribute1';
17+
DELETE FROM scale where id = 'scale_attribute1';
18+
19+
DELETE FROM ontology where id = 'ontology_attribute1';
20+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
DELETE FROM germplasm_external_references where germplasm_entity_id = 'germplasm3';
2+
DELETE FROM external_reference where id = 'germplasm_er_3';
3+
DELETE FROM germplasm_taxon where germplasm_id = 'germplasm3';
4+
DELETE FROM germplasm_synonym where germplasm_id = 'germplasm3';
5+
DELETE FROM germplasm_entity_type_of_germplasm_storage_code where germplasm_entity_id = 'germplasm3';
6+
DELETE FROM germplasm_institute where germplasm_id = 'germplasm3';
7+
DELETE FROM germplasm_origin where germplasm_id = 'germplasm3';
8+
DELETE FROM coordinate where id = 'germplasm_origin_coor_3';
9+
DELETE FROM geojson where id = 'germplasm_origin_geo_3';
10+
DELETE FROM germplasm_donor where germplasm_id = 'germplasm3';
11+
DELETE FROM germplasm where id = 'germplasm3';
12+
13+
DELETE FROM germplasm_external_references where germplasm_entity_id = 'germplasm2';
14+
DELETE FROM external_reference where id = 'germplasm_er_2';
15+
DELETE FROM germplasm_taxon where germplasm_id = 'germplasm2';
16+
DELETE FROM germplasm_synonym where germplasm_id = 'germplasm2';
17+
DELETE FROM germplasm_entity_type_of_germplasm_storage_code where germplasm_entity_id = 'germplasm2';
18+
DELETE FROM germplasm_institute where germplasm_id = 'germplasm2';
19+
DELETE FROM germplasm_origin where germplasm_id = 'germplasm2';
20+
DELETE FROM coordinate where id = 'germplasm_origin_coor_2';
21+
DELETE FROM geojson where id = 'germplasm_origin_geo_2';
22+
DELETE FROM germplasm_donor where germplasm_id = 'germplasm2';
23+
DELETE FROM germplasm where id = 'germplasm2';
24+
25+
DELETE FROM germplasm_external_references where germplasm_entity_id = 'germplasm1';
26+
DELETE FROM external_reference where id = 'germplasm_er_1';
27+
DELETE FROM germplasm_taxon where germplasm_id = 'germplasm1';
28+
DELETE FROM germplasm_synonym where germplasm_id = 'germplasm1';
29+
DELETE FROM germplasm_entity_type_of_germplasm_storage_code where germplasm_entity_id = 'germplasm1';
30+
DELETE FROM germplasm_institute where germplasm_id = 'germplasm1';
31+
DELETE FROM germplasm_origin where germplasm_id = 'germplasm1';
32+
DELETE FROM coordinate where id = 'germplasm_origin_coor_1';
33+
DELETE FROM geojson where id = 'germplasm_origin_geo_1';
34+
DELETE FROM germplasm_donor where germplasm_id = 'germplasm1';
35+
DELETE FROM germplasm where id = 'germplasm1';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DELETE FROM breeding_method where id IN ('breeding_method1', 'breeding_method2');

0 commit comments

Comments
 (0)