From 97cdc8c57365564fa183ab7b275dd443a5d473d2 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Fri, 30 Aug 2024 10:27:01 +0300 Subject: [PATCH 1/6] feat: collect onboarding events in separate table --- .../20240830102144-onboarding-events.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/migrations/20240830102144-onboarding-events.js diff --git a/src/migrations/20240830102144-onboarding-events.js b/src/migrations/20240830102144-onboarding-events.js new file mode 100644 index 000000000000..f868806ab378 --- /dev/null +++ b/src/migrations/20240830102144-onboarding-events.js @@ -0,0 +1,23 @@ +'use strict'; + +exports.up = function (db, cb) { + db.runSql( + ` + CREATE TABLE onboarding_events ( + event VARCHAR(50) NOT NULL, + diff INTEGER NOT NULL, + project VARCHAR(255), + PRIMARY KEY (event, project) + ); + `, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql( + ` + DROP TABLE IF EXISTS onboarding_events; + `, + cb); +}; From c9c010cf5390b3d62e5fa5b35f30cf9cf06093b3 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Fri, 30 Aug 2024 10:34:29 +0300 Subject: [PATCH 2/6] feat: collect onboarding events in separate table --- src/migrations/20240830102144-onboarding-events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/migrations/20240830102144-onboarding-events.js b/src/migrations/20240830102144-onboarding-events.js index f868806ab378..4b76546d9c57 100644 --- a/src/migrations/20240830102144-onboarding-events.js +++ b/src/migrations/20240830102144-onboarding-events.js @@ -4,7 +4,7 @@ exports.up = function (db, cb) { db.runSql( ` CREATE TABLE onboarding_events ( - event VARCHAR(50) NOT NULL, + event VARCHAR(255) NOT NULL, diff INTEGER NOT NULL, project VARCHAR(255), PRIMARY KEY (event, project) From dacddb7fdf78004e83ff8cf934b8258963e9a02f Mon Sep 17 00:00:00 2001 From: sjaanus Date: Fri, 30 Aug 2024 10:57:24 +0300 Subject: [PATCH 3/6] Fix --- .../20240830102144-onboarding-events.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/migrations/20240830102144-onboarding-events.js b/src/migrations/20240830102144-onboarding-events.js index 4b76546d9c57..c1783ed4b21d 100644 --- a/src/migrations/20240830102144-onboarding-events.js +++ b/src/migrations/20240830102144-onboarding-events.js @@ -3,12 +3,19 @@ exports.up = function (db, cb) { db.runSql( ` - CREATE TABLE onboarding_events ( + CREATE TABLE onboarding_events_instance ( + event VARCHAR(255) NOT NULL, + time_to_event INTEGER NOT NULL, + PRIMARY KEY (event) + ); + + CREATE TABLE onboarding_events_project ( event VARCHAR(255) NOT NULL, - diff INTEGER NOT NULL, - project VARCHAR(255), + time_to_event INTEGER NOT NULL, + project VARCHAR(255) REFERENCES projects(id) ON DELETE CASCADE, PRIMARY KEY (event, project) ); + `, cb, ); @@ -17,7 +24,8 @@ exports.up = function (db, cb) { exports.down = function (db, cb) { db.runSql( ` - DROP TABLE IF EXISTS onboarding_events; + DROP TABLE IF EXISTS onboarding_events_instance; + DROP TABLE IF EXISTS onboarding_events_project; `, cb); }; From 4a376730aef8d43a9bc5f92245e3a04875031cd1 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Fri, 30 Aug 2024 10:57:31 +0300 Subject: [PATCH 4/6] Fix --- src/migrations/20240830102144-onboarding-events.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/migrations/20240830102144-onboarding-events.js b/src/migrations/20240830102144-onboarding-events.js index c1783ed4b21d..15b720592434 100644 --- a/src/migrations/20240830102144-onboarding-events.js +++ b/src/migrations/20240830102144-onboarding-events.js @@ -15,7 +15,6 @@ exports.up = function (db, cb) { project VARCHAR(255) REFERENCES projects(id) ON DELETE CASCADE, PRIMARY KEY (event, project) ); - `, cb, ); From e73fd418b000366fee4c0bd19c856807bcb04ed5 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Fri, 30 Aug 2024 11:22:08 +0300 Subject: [PATCH 5/6] Fix --- src/migrations/20240830102144-onboarding-events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/migrations/20240830102144-onboarding-events.js b/src/migrations/20240830102144-onboarding-events.js index 15b720592434..a1b66df5f499 100644 --- a/src/migrations/20240830102144-onboarding-events.js +++ b/src/migrations/20240830102144-onboarding-events.js @@ -12,7 +12,7 @@ exports.up = function (db, cb) { CREATE TABLE onboarding_events_project ( event VARCHAR(255) NOT NULL, time_to_event INTEGER NOT NULL, - project VARCHAR(255) REFERENCES projects(id) ON DELETE CASCADE, + project VARCHAR(255) NOT NULL REFERENCES projects(id) ON DELETE CASCADE, PRIMARY KEY (event, project) ); `, From 91ba258f693395d9a0008083bb93375e8e149c91 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Fri, 30 Aug 2024 11:29:30 +0300 Subject: [PATCH 6/6] Fix --- src/migrations/20240830102144-onboarding-events.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/migrations/20240830102144-onboarding-events.js b/src/migrations/20240830102144-onboarding-events.js index a1b66df5f499..ca8817035042 100644 --- a/src/migrations/20240830102144-onboarding-events.js +++ b/src/migrations/20240830102144-onboarding-events.js @@ -3,15 +3,15 @@ exports.up = function (db, cb) { db.runSql( ` - CREATE TABLE onboarding_events_instance ( + CREATE TABLE IF NOT EXISTS onboarding_events_instance ( event VARCHAR(255) NOT NULL, - time_to_event INTEGER NOT NULL, + time_to_event INTEGER NOT NULL, -- in seconds PRIMARY KEY (event) ); - CREATE TABLE onboarding_events_project ( + CREATE TABLE IF NOT EXISTS onboarding_events_project ( event VARCHAR(255) NOT NULL, - time_to_event INTEGER NOT NULL, + time_to_event INTEGER NOT NULL, -- in seconds project VARCHAR(255) NOT NULL REFERENCES projects(id) ON DELETE CASCADE, PRIMARY KEY (event, project) );