sequent icon indicating copy to clipboard operation
sequent copied to clipboard

How to correctly define joined table migrations

Open nickodelon opened this issue 3 years ago • 0 comments

Hello! At first I want to say that I have been testing out Sequent for a week now and I really like this framework. Great job guys! I hope it will stay maintained and maybe even I will be able to contribute after some time 😄

However, I have a question regarding migrations:

I have three projectors with corresponding manages_table: CourseProjector (course_records, course_lesson_record) UserProjector (user_records) CourseProgressProjector (course_progress_records)

course_progress_records is a joined table between course_records and users_records. it’s migration file:

CREATE TABLE course_progress_records%SUFFIX% (
    id serial NOT NULL,
    uuid uuid NOT NULL,
    course_uuid uuid NOT NULL REFERENCES course_records%SUFFIX%(uuid) ON DELETE CASCADE,
    user_uuid uuid NOT NULL REFERENCES user_records%SUFFIX%(uuid) ON DELETE CASCADE,
    lessons_progresses jsonb,
    overall_progress integer,
    CONSTRAINT course_progress_records_pkey%SUFFIX% PRIMARY KEY (id)
);
CREATE UNIQUE INDEX course_progress_keys%SUFFIX% ON course_progress_records%SUFFIX% USING btree (uuid);
CREATE UNIQUE INDEX course_progress_records_course_uuid_user_uuid_index%SUFFIX% ON course_progress_records%SUFFIX% USING btree (course_uuid, user_uuid);

I think that in current implementation, when I want to migrate and upgrade to a new version and I want only to rebuild CourseProgressProjector, not all projectors, it does not work, because it looks for course_records%SUFFIX% and user_records%SUFFIX% which are not present with a new version suffix.

How to handle joined tables and it’s migrations correctly?

nickodelon avatar Sep 22 '22 10:09 nickodelon