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
chore: add document-id migration #19514
Conversation
Size Change: 0 B Total Size: 2.38 MB ℹ️ View Unchanged
|
79d39f9
to
397e04a
Compare
397e04a
to
b801c7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean! 🚀
I created another ticket to migrate and generate the draft versions of documents when D&P is enabled
database: 'postgres', | ||
user: 'postgres', | ||
password: 'test', | ||
port: 54321, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep the old credentials, as all databases sahre the same ones! is there any reason to change these ones?
const hasLocalizationsJoinTable = async (knex: Knex, tableName: string) => { | ||
return knex.schema.hasTable(`${tableName}_localizations_links`); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how @innerdvations, about shortening table names, is going to affect this bit.
After the first migration to v5, I imagine the table names will have not been shortened in knex schema right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have to update it later, but we can merge this first and I'll take it into account for my feature and fix it.
I actually suspect we will find a lot of little places throughout the codebase with hardcoded names that I'm not currently aware of and can't easily discover until I start testing the shortening and see what breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, I wanted to take a look when reviewing your PR!
packages/core/database/src/migrations/internal-migrations/document-id.ts
Outdated
Show resolved
Hide resolved
packages/core/database/src/migrations/internal-migrations/document-id.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a good way to test this might be to use the V4 e2e data set, i think the tests should(?) still pass at the moment 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about naming it something like 5.0.0-01-document-id.ts
so that we have an easy way to see the version it was introduced in and the order in which the migrations are run? It's not (currently) enforced by the internal migrations loader because we're just using an array, but it could be added later, and in the meantime it would still be helpful to keep things organized as we add more migrations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly a concern of this PR, but since this is our first internal migration:
Do we have a plan or documentation for when a migration fails? It looks like in the case of a catastrophic failure, knex will leave the db lock in place and users will have to manually remove it: https://knexjs.org/guide/migrations.html#notes-about-locks
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Looking forward to this <3 |
packages/core/database/src/migrations/internal-migrations/5.0.0-02-document-id.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge and start getting community members to test the migration cc @derrickmehaffy if you have some candidates for data migration tests soon :)
I would personally wait for #19813 too before testing the v4 data migration |
@innerdvations about the lock, I have only been testing this with sqlite, but at least I did not need to remove any lock if the migration failed. |
What does it do?
Why is it needed?
to migrate from v4 to v5
How to test it?
test moving from v4 to v5 (main to v5/main) and restarting an app will add the document_id column and populate respecting localizations.
Tested
Related issue(s)/PR(s)
Let us know if this is related to any issue/pull request