fix(usage): preserve consent choices and make the prompt accessible
This commit is contained in:
@@ -5,15 +5,21 @@
|
||||
// too, so upgraded and brand-new installs share one "already asked" marker
|
||||
// and neither gets asked twice. Separate from `notice_dismissed`, which
|
||||
// governs the persistent, re-visitable dashboard banner instead.
|
||||
const { formatBoolean } = require('../../src/utils/dbCompat');
|
||||
|
||||
exports.up = async function (knex) {
|
||||
if (
|
||||
(await knex.schema.hasTable('product_usage_state')) &&
|
||||
!(await knex.schema.hasColumn('product_usage_state', 'prompt_shown'))
|
||||
) {
|
||||
if (!(await knex.schema.hasTable('product_usage_state'))) return;
|
||||
if (!(await knex.schema.hasColumn('product_usage_state', 'prompt_shown'))) {
|
||||
await knex.schema.alterTable('product_usage_state', (t) => {
|
||||
t.boolean('prompt_shown').notNullable().defaultTo(false);
|
||||
});
|
||||
}
|
||||
// Existing participants already made their choice before this marker
|
||||
// existed. Preserve it through withdrawal, pending delivery and identity
|
||||
// recovery; none of those transitions should produce a fresh invitation.
|
||||
await knex('product_usage_state')
|
||||
.whereNot('status', 'disabled')
|
||||
.update({ prompt_shown: formatBoolean(true) });
|
||||
};
|
||||
exports.down = async function (knex) {
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user