Skip to content

Commit

Permalink
Merge branch 'development' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Sep 23, 2024
2 parents 44450e7 + 555186c commit cf2cb94
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
5 changes: 2 additions & 3 deletions src/backend/app/db/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,7 @@ class DbSubmissionPhotos(Base):
project_id = cast(
int, Column(Integer, ForeignKey("projects.id"), name="project_id", index=True)
)
task_id = cast(
int, Column(Integer, ForeignKey("tasks.id"), name="task_id", index=True)
)
# Note this is not a DbTask, but an ODK task_id
task_id = cast(int, Column(Integer))
submission_id = cast(str, Column(String))
s3_path = cast(str, Column(String))
11 changes: 0 additions & 11 deletions src/backend/migrations/007-remove-xform-table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ BEGIN
ADD CONSTRAINT fk_project_id FOREIGN KEY (project_id)
REFERENCES public.projects (id);
END IF;

IF NOT EXISTS (
SELECT 1 FROM information_schema.table_constraints
WHERE constraint_name = 'fk_tasks'
AND table_name = 'submission_photos'
) THEN
ALTER TABLE ONLY public.submission_photos
ADD CONSTRAINT fk_tasks FOREIGN KEY (
task_id, project_id
) REFERENCES public.tasks (id, project_id);
END IF;
END $$;

-- Update public.projects table
Expand Down
6 changes: 1 addition & 5 deletions src/backend/migrations/init/fmtm_base_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ ALTER SEQUENCE public.xlsforms_id_seq OWNED BY public.xlsforms.id;
CREATE TABLE public.submission_photos (
id integer NOT NULL,
project_id integer NOT NULL,
-- Note this is not public.tasks, but an ODK task_id
task_id integer NOT NULL,
submission_id character varying NOT NULL,
s3_path character varying NOT NULL
Expand Down Expand Up @@ -600,11 +601,6 @@ ADD CONSTRAINT fk_project_id FOREIGN KEY (
project_id
) REFERENCES public.projects (id);

ALTER TABLE ONLY public.submission_photos
ADD CONSTRAINT fk_tasks FOREIGN KEY (
task_id, project_id
) REFERENCES public.tasks (id, project_id);

-- Finalise

REVOKE USAGE ON SCHEMA public FROM public;
Expand Down

0 comments on commit cf2cb94

Please sign in to comment.