-
Notifications
You must be signed in to change notification settings - Fork 14
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
⬇️ Merge release v5.2 to dev branch with typeorm syntax updates for feature flag #1878
Conversation
(cherry picked from commit b22767d)
That's really annoying. Why can't Typeorm keep track of and discover these things anymore? I know I'll forget to do this step a lot. |
import { removeGroupIdFromIndividualExclusion1721124249413 } from '../database/migrations/1721124249413-removeGroupIdFromIndividualExclusion'; | ||
import { featureFlagFilterModeChangeDefault1722540825048 } from '../database/migrations/1722540825048-featureFlagFilterModeChangeDefault'; | ||
|
||
const entities = [ |
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.
Could we not just use env.app.dirs.entities
instead of having to define this and update it all the time? I tested it locally and it works.
UserStratificationFactor, | ||
]; | ||
|
||
export const 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.
Same here. I was able to use env.app.dirs.migrations
and did not have to define this variable.
migrations: env.app.dirs.migrations, | ||
}); | ||
return connection; | ||
migrations: 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.
I successfully ran tests using env.app.dirs.migration
instead of importing the variable and it worked fine.
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.
It's deprecated and will be removed from the 0.4.0 version. Check the changelog Breaking Change
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.
Lets go with @bcb37 suggestion till they force us to upgrade :)
password: env.db.password, | ||
logging: env.db.logging as LoggerOptions, | ||
entities: env.app.dirs.entities, | ||
migrations: 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.
Here too
"migration:run": "./node_modules/.bin/ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:run", | ||
"migration:generate": "./node_modules/.bin/ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:generate -d src/loaders/typeormLoader.ts", | ||
"migration:create": "./node_modules/.bin/ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:create -d src/loaders/typeormLoader.ts", | ||
"migration:run": "./node_modules/.bin/ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:run -d src/loaders/typeormLoader.ts", | ||
"migration:revert": "./node_modules/.bin/ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:revert" |
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.
We should add the -d flag to the revert
script here too
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 few things I noticed, which were probably in the original pr.
Also, should the migration in the top level 1724745446870-typeormv3-featureFlagUpdates.ts
be moved?
backend/packages/Upgrade/src/api/repositories/AnalyticsRepository.ts
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,50 @@ | |||
import { MigrationInterface, QueryRunner } from "typeorm"; |
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.
Is this file needed?
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.
Yes we need this, somehow the file was created in the Upgrade directory due to recent changes to migration script. Will look into this.
Right, I was also feeling the same as it was done in the old PR for typeorm changes and I was going to look for a solution. Yes, indeed |
@bcb37 @VivekFitkariwala Made changes as requested to remove excess changes to the datasource typeLoader file related to annoying updates to the entities and migration on each new addition. We can update once its forced in typeorm v0.4. Also, checked the migration scripts and resolved them to generate migration files in proper directory
The other two migration scripts for
Also, I had to update the typeormloader to have a default export of the datasource due to following error after removing the entities and migrations export from it:
|
Once, this is approved, will add these changes in the slack and gitbook documentation. |
…into feature-flags/merge-typeorm-v0.3-updates
…into feature-flags/merge-typeorm-v0.3-updates
Context
This PR is to resolve #1875. Here we want to pull the typeORM v0.3.0 update related changes to dev branch to release v6.0 with feature flags.
Summary
Here I have made a new branch
release/v6.0
fromdev
branch and pulled inrelease/v5.2
branch. Updated typeorm syntax for feature flag related code.Key Changes
dev
branch.{ primary: true }
option to define a column as primary key is not supported for relational columns like@ManyToMany, @OneToMany
. We need to define separate@PrimaryColumn
and use@JoinColum
with the relational column. This is done in this PR for feature flag related models.typeORMLoader.ts
file, we need to add any new entities/models that we create and also add any new migrations class.