Skip to content

Commit be15ddf

Browse files
authored
Merge pull request #188 from chingu-x/dev
End of Sprint 26 merge into main
2 parents 1f663be + 6d01dfa commit be15ddf

File tree

25 files changed

+1921
-456
lines changed

25 files changed

+1921
-456
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ Another example [here](https://co-pilot.dev/changelog)
1010

1111
### Added
1212

13+
### Changed
14+
15+
### Fixed
16+
17+
### Removed
18+
19+
## [v1.0.0-alpha]
20+
21+
### Added
22+
1323
- Add @ApiResponse tags to resources ([#76](https://github.com/chingu-x/chingu-dashboard-be/pull/76))
1424
- Add @ApiResponse tags to ideations and features ([#65](https://github.com/chingu-x/chingu-dashboard-be/pull/77))
1525
- Add refresh token functionality and global guard to protect all routes ([#78](https://github.com/chingu-x/chingu-dashboard-be/pull/78))
@@ -48,11 +58,17 @@ Another example [here](https://co-pilot.dev/changelog)
4858
- Add CASL permissions for Tech endpoint ([#174](https://github.com/chingu-x/chingu-dashboard-be/pull/174))
4959
- Add CASL permissions for Team Resource endpoint ([#177](https://github.com/chingu-x/chingu-dashboard-be/pull/177))
5060
- Add units tests for the users controller & services([#179](https://github.com/chingu-x/chingu-dashboard-be/pull/178))
61+
- Add CASL permissions for Team features endpoint ([#184](https://github.com/chingu-x/chingu-dashboard-be/pull/184))
62+
- Add production seed for alpha test ([#185](https://github.com/chingu-x/chingu-dashboard-be/pull/185))
63+
64+
65+
66+
- Add units tests for the teams controller & services([#189](https://github.com/chingu-x/chingu-dashboard-be/pull/189))
5167

5268
### Changed
5369

5470
- Update docker compose and scripts in package.json to include a test database container and remove usage of .env.dev to avoid confusion ([#100](https://github.com/chingu-x/chingu-dashboard-be/pull/100))
55-
- Restructure seed/index.ts to work with e2e tests, and add --runInBand to e2e scripts[#101](https://github.com/chingu-x/chingu-dashboard-be/pull/101)
71+
- Restructure seed/-index.ts to work with e2e tests, and add --runInBand to e2e scripts[#101](https://github.com/chingu-x/chingu-dashboard-be/pull/101)
5672
- Update changelog ([#104](https://github.com/chingu-x/chingu-dashboard-be/pull/104))
5773
- Update test.yml to run e2e tests on pull requests to the main branch [#105](https://github.com/chingu-x/chingu-dashboard-be/pull/105)
5874
- Update email templates to use domain in environment variables [#110](https://github.com/chingu-x/chingu-dashboard-be/pull/110)
@@ -90,6 +106,7 @@ Another example [here](https://co-pilot.dev/changelog)
90106
- Fix form responses giving error and not inserting values when the boolean value is false ([#156](https://github.com/chingu-x/chingu-dashboard-be/pull/156))
91107
- Fix a bug for check on voyageTeamMemberId ([#159](https://github.com/chingu-x/chingu-dashboard-be/pull/159))
92108
- Fix users unit test failing due to a schema change
109+
- Fix seed data for alpha test (check in form question changes, gravatar) ([#190](https://github.com/chingu-x/chingu-dashboard-be/pull/190))
93110

94111
### Removed
95112

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"studio:test": "dotenv -e ./.env.test prisma studio",
2727
"studio:test:docker": "dotenv -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public prisma studio",
2828
"seed": "prisma db seed",
29+
"seed:prod": "dotenv -e .env.production.local ts-node prisma/production-seed/index.ts",
2930
"lint": "eslint \"{prisma/*seed,src,test}/**/*.ts\" --fix",
3031
"test:unit": "dotenv -e ./.env.test jest",
3132
"test:unit:docker": "dotenv -v NODE_ENV=test -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public jest",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- A unique constraint covering the columns `[name]` on the table `OAuthProvider` will be added. If there are existing duplicate values, this will fail.
5+
6+
*/
7+
-- CreateIndex
8+
CREATE UNIQUE INDEX "OAuthProvider_name_key" ON "OAuthProvider"("name");

prisma/production-seed/data.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

prisma/production-seed/forms.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { populateMeetingForms } from "../seed/forms/meeting-forms";
2+
import { populateCheckinForm } from "../seed/forms/checkinform";
3+
import { populateCheckinFormPO } from "../seed/forms/checkinformPO";
4+
import { populateCheckinFormSM } from "../seed/forms/checkinformSM";
5+
import { populateVoyageSubmissionForm } from "../seed/forms/voyage-project-submission";
6+
7+
export const populateFormsProd = async () => {
8+
await populateMeetingForms();
9+
await populateCheckinForm();
10+
await populateCheckinFormPO();
11+
await populateCheckinFormSM();
12+
await populateVoyageSubmissionForm();
13+
14+
console.log("[Prod] Forms table populated.");
15+
};

prisma/production-seed/index.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { populateTables } from "../seed/tables";
2+
import { prisma } from "../seed/prisma-client";
3+
import { populateVoyagesProd } from "./voyages";
4+
import { populateSprints } from "../seed/sprints";
5+
import { populateUsersProd } from "./users";
6+
import { populateVoyageTeamsProd } from "./teams";
7+
import { populateFormsProd } from "./forms";
8+
9+
export const deleteAllTables = async () => {
10+
const tablenames = await prisma.$queryRaw<
11+
Array<{ tablename: string }>
12+
>`SELECT tablename FROM pg_tables WHERE schemaname='public'`;
13+
14+
const tables = tablenames
15+
.map(({ tablename }) => tablename)
16+
.filter((name) => name !== "_prisma_migrations")
17+
.map((name) => `"public"."${name}"`)
18+
.join(", ");
19+
20+
try {
21+
await prisma.$executeRawUnsafe(
22+
`TRUNCATE TABLE ${tables} RESTART IDENTITY CASCADE;`,
23+
);
24+
} catch (error) {
25+
console.log({ error });
26+
}
27+
console.log("===\n[Production] All tables deleted.\n===");
28+
};
29+
30+
(async function () {
31+
await deleteAllTables();
32+
await populateTables(); // tables with no relations
33+
await populateVoyagesProd();
34+
await populateSprints();
35+
await populateUsersProd();
36+
await populateVoyageTeamsProd();
37+
await populateFormsProd();
38+
39+
console.log("===\n🌱 [Production] Database seeding completed.\n===");
40+
41+
prisma.$disconnect();
42+
})();

0 commit comments

Comments
 (0)