1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00
unleash.unleash/src/migrations/20230420211308-update-context-fields-add-sessionId.js

23 lines
533 B
JavaScript
Raw Normal View History

fix: override built in stickiness options (#3563) <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> Created migration for updating context fields Context fields with stickiness are now the source of truth for stickiness options. ## About the changes `userId` context field is updated to have stickiness on by default `sessionId` context field is added with stickiness on by default If `default` or `random` are not part of the context field - we add them This will allow for the option to disable them, by creating a eg. `random` context field with stickiness off https://user-images.githubusercontent.com/104830839/233581147-9a514af4-1fdd-4c2e-b954-3cfa13b1a203.mov <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes to # [1-794](https://linear.app/unleash/issue/1-794/reach-out-to-yousician-for-early-beta-test) <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-04-21 16:13:42 +02:00
'use strict';
exports.up = function (db, callback) {
db.runSql(
`
fix: migration failure when sessionId exists (#3624) (#3625) <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> Back-porting the migration fix ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-04-26 11:00:13 +02:00
INSERT INTO context_fields(name, description, sort_order, stickiness) VALUES('sessionId', 'Allows you to constrain on sessionId', 4, true) ON CONFLICT DO NOTHING;
fix: override built in stickiness options (#3563) <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> Created migration for updating context fields Context fields with stickiness are now the source of truth for stickiness options. ## About the changes `userId` context field is updated to have stickiness on by default `sessionId` context field is added with stickiness on by default If `default` or `random` are not part of the context field - we add them This will allow for the option to disable them, by creating a eg. `random` context field with stickiness off https://user-images.githubusercontent.com/104830839/233581147-9a514af4-1fdd-4c2e-b954-3cfa13b1a203.mov <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes to # [1-794](https://linear.app/unleash/issue/1-794/reach-out-to-yousician-for-early-beta-test) <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-04-21 16:13:42 +02:00
UPDATE context_fields
SET stickiness = true
WHERE name LIKE 'userId' AND stickiness is null;
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(
`
`,
callback,
);
};