Skip to content

Commit 6e6f814

Browse files
authored
Merge pull request #940 from ctti-clinicaltrials/dev
Release 6.2.2
2 parents f6bda8f + 9ae2911 commit 6e6f814

File tree

5 files changed

+142
-4
lines changed

5 files changed

+142
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ server.env
1919
.byebug_history
2020
/config/connections.yml
2121
data
22-
/public/static/documentation/schema.dot
22+
/public/static/documentation/schema.dot
23+
/storage

app/models/search_result.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def self.make_tsv(condition = 'covid-19')
2828
end
2929
filename = "#{name}.tsv"
3030
record = FileRecord.create(file_type: condition, filename: filename)
31-
record.file.attach(io: File.open(file_path), filename: "#{name}.tsv")
31+
record.file.attach(io: File.open(file), filename: "#{name}.tsv")
3232
end
3333

3434
def self.study_values(study)

app/models/util/file_manager.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ def save_static_copy(schema='ctgov')
219219
filename = File.basename(zip_file_name)
220220
record = FileRecord.create(file_type: "snapshot", filename: "#{filename}")
221221
record.file.attach(io: File.open(zip_file_name), filename: "#{filename}")
222+
record.update(url: Rails.application.routes.url_helpers.rails_blob_path(file.file, only_path: true))
223+
222224
zip_file_name
223225
end
224226

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddUrlToFileRecord < ActiveRecord::Migration[6.0]
2+
def change
3+
add_column :file_records, :url, :string
4+
end
5+
end

db/structure.sql

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,74 @@ SET default_tablespace = '';
282282

283283
SET default_table_access_method = heap;
284284

285+
--
286+
-- Name: active_storage_attachments; Type: TABLE; Schema: ctgov; Owner: -
287+
--
288+
289+
CREATE TABLE ctgov.active_storage_attachments (
290+
id bigint NOT NULL,
291+
name character varying NOT NULL,
292+
record_type character varying NOT NULL,
293+
record_id bigint NOT NULL,
294+
blob_id bigint NOT NULL,
295+
created_at timestamp without time zone NOT NULL
296+
);
297+
298+
299+
--
300+
-- Name: active_storage_attachments_id_seq; Type: SEQUENCE; Schema: ctgov; Owner: -
301+
--
302+
303+
CREATE SEQUENCE ctgov.active_storage_attachments_id_seq
304+
START WITH 1
305+
INCREMENT BY 1
306+
NO MINVALUE
307+
NO MAXVALUE
308+
CACHE 1;
309+
310+
311+
--
312+
-- Name: active_storage_attachments_id_seq; Type: SEQUENCE OWNED BY; Schema: ctgov; Owner: -
313+
--
314+
315+
ALTER SEQUENCE ctgov.active_storage_attachments_id_seq OWNED BY ctgov.active_storage_attachments.id;
316+
317+
318+
--
319+
-- Name: active_storage_blobs; Type: TABLE; Schema: ctgov; Owner: -
320+
--
321+
322+
CREATE TABLE ctgov.active_storage_blobs (
323+
id bigint NOT NULL,
324+
key character varying NOT NULL,
325+
filename character varying NOT NULL,
326+
content_type character varying,
327+
metadata text,
328+
byte_size bigint NOT NULL,
329+
checksum character varying NOT NULL,
330+
created_at timestamp without time zone NOT NULL
331+
);
332+
333+
334+
--
335+
-- Name: active_storage_blobs_id_seq; Type: SEQUENCE; Schema: ctgov; Owner: -
336+
--
337+
338+
CREATE SEQUENCE ctgov.active_storage_blobs_id_seq
339+
START WITH 1
340+
INCREMENT BY 1
341+
NO MINVALUE
342+
NO MAXVALUE
343+
CACHE 1;
344+
345+
346+
--
347+
-- Name: active_storage_blobs_id_seq; Type: SEQUENCE OWNED BY; Schema: ctgov; Owner: -
348+
--
349+
350+
ALTER SEQUENCE ctgov.active_storage_blobs_id_seq OWNED BY ctgov.active_storage_blobs.id;
351+
352+
285353
--
286354
-- Name: browse_conditions; Type: TABLE; Schema: ctgov; Owner: -
287355
--
@@ -1462,7 +1530,8 @@ CREATE TABLE ctgov.file_records (
14621530
file_size bigint,
14631531
file_type character varying,
14641532
created_at timestamp(6) without time zone NOT NULL,
1465-
updated_at timestamp(6) without time zone NOT NULL
1533+
updated_at timestamp(6) without time zone NOT NULL,
1534+
url character varying
14661535
);
14671536

14681537

@@ -2590,6 +2659,20 @@ CREATE SEQUENCE support.study_xml_records_id_seq
25902659
ALTER SEQUENCE support.study_xml_records_id_seq OWNED BY support.study_xml_records.id;
25912660

25922661

2662+
--
2663+
-- Name: active_storage_attachments id; Type: DEFAULT; Schema: ctgov; Owner: -
2664+
--
2665+
2666+
ALTER TABLE ONLY ctgov.active_storage_attachments ALTER COLUMN id SET DEFAULT nextval('ctgov.active_storage_attachments_id_seq'::regclass);
2667+
2668+
2669+
--
2670+
-- Name: active_storage_blobs id; Type: DEFAULT; Schema: ctgov; Owner: -
2671+
--
2672+
2673+
ALTER TABLE ONLY ctgov.active_storage_blobs ALTER COLUMN id SET DEFAULT nextval('ctgov.active_storage_blobs_id_seq'::regclass);
2674+
2675+
25932676
--
25942677
-- Name: baseline_counts id; Type: DEFAULT; Schema: ctgov; Owner: -
25952678
--
@@ -2968,6 +3051,22 @@ ALTER TABLE ONLY support.study_json_records ALTER COLUMN id SET DEFAULT nextval(
29683051
ALTER TABLE ONLY support.study_xml_records ALTER COLUMN id SET DEFAULT nextval('support.study_xml_records_id_seq'::regclass);
29693052

29703053

3054+
--
3055+
-- Name: active_storage_attachments active_storage_attachments_pkey; Type: CONSTRAINT; Schema: ctgov; Owner: -
3056+
--
3057+
3058+
ALTER TABLE ONLY ctgov.active_storage_attachments
3059+
ADD CONSTRAINT active_storage_attachments_pkey PRIMARY KEY (id);
3060+
3061+
3062+
--
3063+
-- Name: active_storage_blobs active_storage_blobs_pkey; Type: CONSTRAINT; Schema: ctgov; Owner: -
3064+
--
3065+
3066+
ALTER TABLE ONLY ctgov.active_storage_blobs
3067+
ADD CONSTRAINT active_storage_blobs_pkey PRIMARY KEY (id);
3068+
3069+
29713070
--
29723071
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: ctgov; Owner: -
29733072
--
@@ -3416,6 +3515,27 @@ ALTER TABLE ONLY support.study_xml_records
34163515
ADD CONSTRAINT study_xml_records_pkey PRIMARY KEY (id);
34173516

34183517

3518+
--
3519+
-- Name: index_active_storage_attachments_on_blob_id; Type: INDEX; Schema: ctgov; Owner: -
3520+
--
3521+
3522+
CREATE INDEX index_active_storage_attachments_on_blob_id ON ctgov.active_storage_attachments USING btree (blob_id);
3523+
3524+
3525+
--
3526+
-- Name: index_active_storage_attachments_uniqueness; Type: INDEX; Schema: ctgov; Owner: -
3527+
--
3528+
3529+
CREATE UNIQUE INDEX index_active_storage_attachments_uniqueness ON ctgov.active_storage_attachments USING btree (record_type, record_id, name, blob_id);
3530+
3531+
3532+
--
3533+
-- Name: index_active_storage_blobs_on_key; Type: INDEX; Schema: ctgov; Owner: -
3534+
--
3535+
3536+
CREATE UNIQUE INDEX index_active_storage_blobs_on_key ON ctgov.active_storage_blobs USING btree (key);
3537+
3538+
34193539
--
34203540
-- Name: index_baseline_measurements_on_category; Type: INDEX; Schema: ctgov; Owner: -
34213541
--
@@ -4095,6 +4215,14 @@ CREATE INDEX "index_support.study_xml_records_on_nct_id" ON support.study_xml_re
40954215
CREATE TRIGGER category_insert_trigger INSTEAD OF INSERT ON ctgov.categories FOR EACH ROW EXECUTE FUNCTION ctgov.category_insert_function();
40964216

40974217

4218+
--
4219+
-- Name: active_storage_attachments fk_rails_c3b3935057; Type: FK CONSTRAINT; Schema: ctgov; Owner: -
4220+
--
4221+
4222+
ALTER TABLE ONLY ctgov.active_storage_attachments
4223+
ADD CONSTRAINT fk_rails_c3b3935057 FOREIGN KEY (blob_id) REFERENCES ctgov.active_storage_blobs(id);
4224+
4225+
40984226
--
40994227
-- Name: sanity_checks fk_rails_9d86ec7e91; Type: FK CONSTRAINT; Schema: support; Owner: -
41004228
--
@@ -4139,6 +4267,8 @@ INSERT INTO "schema_migrations" (version) VALUES
41394267
('20210601063550'),
41404268
('20211027133828'),
41414269
('20220202152642'),
4142-
('20220212033048');
4270+
('20220212033048'),
4271+
('20220308030627'),
4272+
('20220329173304');
41434273

41444274

0 commit comments

Comments
 (0)