Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-10, ISSUE-9: Using migrations now isntead of sync and fix short-index collision #11

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Souvent22
Copy link

@Souvent22 Souvent22 commented May 19, 2021

Fix short-index Collision and Use Migrations instead of sync()

Fixes

This branch uses migrations and removes the use of .sync().
This is important in a production setting because sync() is sometimes unpredictable and destructive in regards to data.

This also adds the options to not run migrations so that one may create a separate script to run migrations.

This also fixes the "short index" issue of ISSUE-9

Tickets Included

#10
#9

Breaking Change

If one already has their ltijs deployed, this is a breaking change. There is a way around that. The strategy is to update the migration table to be what it is before the hash-token upgrade and then the next upgrade for hash-tokens column will run fine. The steps are:

  1. Run the following sql BEFORE upgrading/switching to this branch:
DELETE FROM `SequelizeMeta`;
INSERT INTO `SequelizeMeta` (`name`)
VALUES
	('00_initialCreation.js'),
	('01_addAuthorizationServer.js');
  1. Switch to this branch and run migrations as normal.
  2. Have some coffee 🍸

@Souvent22
Copy link
Author

Did some end to end testing with and found some minor issues. All resolved now and should be good for review.

@Souvent22 Souvent22 changed the title ISSUE-10: Using migrations now isntead of sync. ISSUE-10, ISSUE-9: Using migrations now isntead of sync and fix short-index collision May 19, 2021
@PanopticaRising
Copy link

PanopticaRising commented May 19, 2021

I mentioned unrelatedly in a ticket I just opened with a very specific problem with migrations, but you might want to consider wrapping the migrations in a Sequelize Transaction so that they don't get partially applied on failure.

There's an example of using transactions with migrations here; it should just involve wrapping the for-loop logic where the actual inserts are happening with this callback:

return queryInterface.sequelize.transaction(t => {

(P.S., I fully support the move to migrations, even if it's breaking my use case 😂)

@Souvent22
Copy link
Author

I'll add some notes to the main branch about how to use this and it not be a breaking change. If one updates their SeuqllizeMeta table before switching to this branch, it should be fine.

@Cvmcosta
Copy link
Owner

Hey, thanks a lot for your work on this PR. I have been extremely busy this last month and the ltijs related projects are basically in stand by while i deal with some issues. I should be getting back to it soon and reviewing/merging this is at the top of the list. Sorry for the delay.

@Souvent22
Copy link
Author

Rebuild to resolve conflicts.

@Souvent22
Copy link
Author

Bump; just wanted to check the status on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants