Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#646 feat: add seed data for dummy users #647

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open

Conversation

usrrname
Copy link
Contributor

@usrrname usrrname commented Mar 14, 2025

Changes

  • adds seeds/ folder and script for opting in to seed dummy users

  • include env_file property on docker-compose to read from .env variable changes a user might make during development

Testing:

Screenshot 2025-03-24 at 9 55 59 AM Screenshot 2025-03-24 at 9 55 07 AM

created [email protected], was able to log in with autogenerated password

#646

TODO:

  • make use of seed opt-in

@usrrname usrrname marked this pull request as ready for review March 14, 2025 21:28
@usrrname usrrname requested a review from evert March 14, 2025 21:36
@evert
Copy link
Member

evert commented Mar 15, 2025

Was this tested if you got an error?

@usrrname usrrname force-pushed the feat/646-seed-data branch from e45c656 to e3abaa3 Compare March 16, 2025 01:44
@usrrname usrrname force-pushed the feat/646-seed-data branch 7 times, most recently from 48ced72 to 1659c52 Compare March 16, 2025 05:01
@usrrname
Copy link
Contributor Author

Was this tested if you got an error?

Yep... working through these... tons of null value in column "field" of relation "table-name" violates not-null constraint

@usrrname usrrname force-pushed the feat/646-seed-data branch 6 times, most recently from 967094b to a888f27 Compare March 17, 2025 01:27
@evert
Copy link
Member

evert commented Mar 17, 2025

Last night I did get something going in, but it was still breaking

I noticed this was force-pushed after. Was this still an issue? Don't 100% understand how that could happen!

@usrrname usrrname force-pushed the feat/646-seed-data branch from a888f27 to a03a1b7 Compare March 17, 2025 20:06
@usrrname
Copy link
Contributor Author

The force-push was a result of me making changes, squashing a commit and pushing it up :p

@usrrname
Copy link
Contributor Author

Rebased... and still err-ing:

of note: PostgreSQL Database directory appears to contain a database; Skipping initialization
Seems like if there was already some data on a mounted volume, the migrations wont run.

Full Trace
Attaching to a12n-server-1, db-1
db-1           | 
db-1           | PostgreSQL Database directory appears to contain a database; Skipping initialization
db-1           | 
db-1           | 2025-03-17 23:20:34.425 UTC [1] LOG:  starting PostgreSQL 17.2 (Debian 17.2-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
db-1           | 2025-03-17 23:20:34.425 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db-1           | 2025-03-17 23:20:34.425 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db-1           | 2025-03-17 23:20:34.426 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db-1           | 2025-03-17 23:20:34.429 UTC [29] LOG:  database system was shut down at 2025-03-17 23:19:02 UTC
db-1           | 2025-03-17 23:20:34.434 UTC [1] LOG:  database system is ready to accept connections
a12n-server-1  | ⚾ @curveball/a12n-server 0.30.0
a12n-server-1  | PUBLIC_URI environment variable was not set, defaulting to http://localhost:8531/
a12n-server-1  | Running database migrations
a12n-server-1  | Running database seeds
db-1           | 2025-03-17 23:20:35.294 UTC [33] ERROR:  column "principal_id" of relation "user_info" does not exist at character 73
db-1           | 2025-03-17 23:20:35.294 UTC [33] STATEMENT:  insert into "user_info" ("family_name", "given_name", "locale", "name", "principal_id") values ($1, $2, $3, $4, $5)
a12n-server-1  | Migrations failed Error: Error while executing "/opt/app/dist/seeds/001_users.js" seed: insert into "user_info" ("family_name", "given_name", "locale", "name", "principal_id") values ($1, $2, $3, $4, $5) - column "principal_id" of relation "user_info" does not exist
a12n-server-1  |     at Seeder._waterfallBatch (/opt/app/node_modules/knex/lib/migrations/seed/Seeder.js:118:23)
a12n-server-1  | error: insert into "user_info" ("family_name", "given_name", "locale", "name", "principal_id") values ($1, $2, $3, $4, $5) - column "principal_id" of relation "user_info" does not exist
a12n-server-1  |     at Parser.parseErrorMessage (/opt/app/node_modules/pg-protocol/dist/parser.js:283:98)
a12n-server-1  |     at Parser.handlePacket (/opt/app/node_modules/pg-protocol/dist/parser.js:122:29)
a12n-server-1  |     at Parser.parse (/opt/app/node_modules/pg-protocol/dist/parser.js:35:38)
a12n-server-1  |     at Socket.<anonymous> (/opt/app/node_modules/pg-protocol/dist/index.js:11:42)
a12n-server-1  |     at Socket.emit (node:events:524:28)
a12n-server-1  |     at addChunk (node:internal/streams/readable:561:12)
a12n-server-1  |     at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
a12n-server-1  |     at Readable.push (node:internal/streams/readable:392:5)
a12n-server-1  |     at TCP.onStreamRead (node:internal/stream_base_commons:191:23) {
a12n-server-1  |   original: error: insert into "user_info" ("family_name", "given_name", "locale", "name", "principal_id") values ($1, $2, $3, $4, $5) - column "principal_id" of relation "user_info" does not exist
a12n-server-1  |       at Parser.parseErrorMessage (/opt/app/node_modules/pg-protocol/dist/parser.js:283:98)
a12n-server-1  |       at Parser.handlePacket (/opt/app/node_modules/pg-protocol/dist/parser.js:122:29)
a12n-server-1  |       at Parser.parse (/opt/app/node_modules/pg-protocol/dist/parser.js:35:38)
a12n-server-1  |       at Socket.<anonymous> (/opt/app/node_modules/pg-protocol/dist/index.js:11:42)
a12n-server-1  |       at Socket.emit (node:events:524:28)
a12n-server-1  |       at addChunk (node:internal/streams/readable:561:12)
a12n-server-1  |       at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
a12n-server-1  |       at Readable.push (node:internal/streams/readable:392:5)
a12n-server-1  |       at TCP.onStreamRead (node:internal/stream_base_commons:191:23) {
a12n-server-1  |     length: 134,
a12n-server-1  |     severity: 'ERROR',
a12n-server-1  |     code: '42703',
a12n-server-1  |     detail: undefined,
a12n-server-1  |     hint: undefined,
a12n-server-1  |     position: '73',
a12n-server-1  |     internalPosition: undefined,
a12n-server-1  |     internalQuery: undefined,
a12n-server-1  |     where: undefined,
a12n-server-1  |     schema: undefined,
a12n-server-1  |     table: undefined,
a12n-server-1  |     column: undefined,
a12n-server-1  |     dataType: undefined,
a12n-server-1  |     constraint: undefined,
a12n-server-1  |     file: 'parse_target.c',
a12n-server-1  |     line: '1065',
a12n-server-1  |     routine: 'checkInsertTargets'
a12n-server-1  |   }
a12n-server-1  | }
a12n-server-1 exited with code 1
Gracefully stopping... (press Ctrl+C again to force)

@usrrname usrrname force-pushed the feat/646-seed-data branch 2 times, most recently from a4c20a3 to 992bb23 Compare March 22, 2025 18:15
@usrrname
Copy link
Contributor Author

Now.. it seems I can set seed.user / process.env.SEED_USER or cors.allowOrigin/process.env.CORS_ALLOW_ORIGIN in .env independently. However, if I set both, I'll get this error when I try to login with the admin user

Screenshot 2025-03-22 at 2 53 47 PM

@usrrname usrrname requested a review from evert March 22, 2025 18:57
usrrname and others added 29 commits April 7, 2025 12:44
Co-authored-by: Evert Pot <[email protected]>
Co-authored-by: Evert Pot <[email protected]>
@usrrname usrrname force-pushed the feat/646-seed-data branch from 361e1b5 to 8908b91 Compare April 7, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants