Skip to content

Commit 9e65d14

Browse files
Merge pull request #575 from biocore/csymons_copy_barcodes
Copy Barcodes
2 parents 19005da + 4883200 commit 9e65d14

File tree

1 file changed

+92
-0
lines changed
  • microsetta_private_api/db/patches

1 file changed

+92
-0
lines changed
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
-- This database patch copies two samples into new barcodes to reflect
2+
-- adjustments that were necessary in the wet lab. We don't believe this
3+
-- will be an ongoing need, but if it proves to be, check for new
4+
-- barcode-related tables before using this as a template.
5+
6+
-- Begin copying X00236845 to 0364352596
7+
INSERT INTO barcodes.barcode (barcode, assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id)
8+
SELECT '0364352596', assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id
9+
FROM barcodes.barcode
10+
WHERE barcode = 'X00236845';
11+
12+
INSERT INTO barcodes.project_barcode (project_id, barcode)
13+
SELECT project_id, '0364352596'
14+
FROM barcodes.project_barcode
15+
WHERE barcode = 'X00236845';
16+
17+
-- I'm omitting the sample_barcode_file and sample_barcode_file_md5 as they're
18+
-- no longer used and it would be inappropriate to directly clone a different
19+
-- barcode's associated file.
20+
INSERT INTO ag.ag_kit_barcodes (ag_kit_id, barcode, site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update)
21+
SELECT ag_kit_id, '0364352596', site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update
22+
FROM ag.ag_kit_barcodes
23+
WHERE barcode = 'X00236845';
24+
25+
INSERT INTO ag.source_barcodes_surveys (barcode, survey_id)
26+
SELECT '0364352596', survey_id
27+
FROM ag.source_barcodes_surveys
28+
WHERE barcode = 'X00236845';
29+
30+
INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, technician_notes)
31+
SELECT '0364352596', scan_timestamp, sample_status, technician_notes
32+
FROM barcodes.barcode_scans
33+
WHERE barcode = 'X00236845';
34+
35+
INSERT INTO ag.vioscreen_registry (account_id, source_id, sample_id, vio_id, deleted, registration_code)
36+
WITH temp_1 AS (
37+
SELECT vr.account_id, vr.source_id, vr.vio_id, vr.deleted, vr.registration_code
38+
FROM ag.vioscreen_registry vr
39+
INNER JOIN ag.ag_kit_barcodes akb ON vr.sample_id = akb.ag_kit_barcode_id
40+
WHERE akb.barcode = 'X00236845'
41+
),
42+
temp_2 AS (
43+
SELECT ag_kit_barcode_id
44+
FROM ag.ag_kit_barcodes
45+
WHERE barcode = '0364352596'
46+
)
47+
SELECT temp_1.account_id, temp_1.source_id, temp_2.ag_kit_barcode_id, temp_1.vio_id, temp_1.deleted, temp_1.registration_code FROM temp_1, temp_2;
48+
-- End copying X00236845 to 0364352596
49+
50+
-- Begin copying 000031307 to 0364406520
51+
INSERT INTO barcodes.barcode (barcode, assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id)
52+
SELECT '0364406520', assigned_on, status, sample_postmark_date, biomass_remaining, sequencing_status, obsolete, create_date_time, kit_id
53+
FROM barcodes.barcode
54+
WHERE barcode = '000031307';
55+
56+
INSERT INTO barcodes.project_barcode (project_id, barcode)
57+
SELECT project_id, '0364406520'
58+
FROM barcodes.project_barcode
59+
WHERE barcode = '000031307';
60+
61+
-- I'm omitting the sample_barcode_file and sample_barcode_file_md5 as they're
62+
-- no longer used and it would be inappropriate to directly clone a different
63+
-- barcode's associated file.
64+
INSERT INTO ag.ag_kit_barcodes (ag_kit_id, barcode, site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update)
65+
SELECT ag_kit_id, '0364406520', site_sampled, sample_date, sample_time, notes, moldy, overloaded, other, other_text, date_of_last_email, results_ready, withdrawn, refunded, deposited, source_id, latest_sample_information_update
66+
FROM ag.ag_kit_barcodes
67+
WHERE barcode = '000031307';
68+
69+
INSERT INTO ag.source_barcodes_surveys (barcode, survey_id)
70+
SELECT '0364406520', survey_id
71+
FROM ag.source_barcodes_surveys
72+
WHERE barcode = '000031307';
73+
74+
INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, technician_notes)
75+
SELECT '0364406520', scan_timestamp, sample_status, technician_notes
76+
FROM barcodes.barcode_scans
77+
WHERE barcode = '000031307';
78+
79+
INSERT INTO ag.vioscreen_registry (account_id, source_id, sample_id, vio_id, deleted, registration_code)
80+
WITH temp_1 AS (
81+
SELECT vr.account_id, vr.source_id, vr.vio_id, vr.deleted, vr.registration_code
82+
FROM ag.vioscreen_registry vr
83+
INNER JOIN ag.ag_kit_barcodes akb ON vr.sample_id = akb.ag_kit_barcode_id
84+
WHERE akb.barcode = '000031307'
85+
),
86+
temp_2 AS (
87+
SELECT ag_kit_barcode_id
88+
FROM ag.ag_kit_barcodes
89+
WHERE barcode = '0364406520'
90+
)
91+
SELECT temp_1.account_id, temp_1.source_id, temp_2.ag_kit_barcode_id, temp_1.vio_id, temp_1.deleted, temp_1.registration_code FROM temp_1, temp_2;
92+
-- End copying 000031307 to 0364406520

0 commit comments

Comments
 (0)