Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a new project column to segments table (#3263)
## About the changes Adds a migration and persistence layer with a new column `segment_project_id` to bind a segment to a project.
- Loading branch information
1 parent
e4b84bc
commit 98d462d
Showing
7 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/migrations/20230306103400-add-project-column-to-segments.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
exports.up = function (db, cb) { | ||
db.runSql( | ||
`ALTER TABLE segments ADD COLUMN segment_project_id varchar(255) REFERENCES projects(id) ON DELETE CASCADE;`, | ||
cb, | ||
); | ||
}; | ||
|
||
exports.down = function (db, cb) { | ||
db.runSql( | ||
`ALTER TABLE segments DROP COLUMN IF EXISTS segment_project_id;`, | ||
cb, | ||
); | ||
}; |
32 changes: 32 additions & 0 deletions
32
src/test/e2e/stores/feature-toggle-client-store.e2e.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import dbInit from '../helpers/database-init'; | ||
import getLogger from '../../fixtures/no-logger'; | ||
import { setupApp } from '../helpers/test-helper'; | ||
|
||
let stores; | ||
let app; | ||
let db; | ||
let featureToggleClientStore; | ||
|
||
beforeAll(async () => { | ||
getLogger.setMuteError(true); | ||
db = await dbInit('feature_toggle_client_store_serial', getLogger); | ||
app = await setupApp(db.stores); | ||
stores = db.stores; | ||
featureToggleClientStore = stores.featureToggleClientStore; | ||
}); | ||
|
||
afterAll(async () => { | ||
await app.destroy(); | ||
await db.destroy(); | ||
}); | ||
|
||
test('should be able to fetch client toggles', async () => { | ||
const response = await app.request | ||
.post('/api/admin/state/import?drop=true') | ||
.attach('file', 'src/test/examples/exported-segments.json'); | ||
|
||
expect(response.status).toBe(202); | ||
|
||
const clientToggles = await featureToggleClientStore.getClient(); | ||
expect(clientToggles).toHaveLength(1); | ||
}); |