Skip to content

Change the public schema name with ENV vars#445

Merged
DZakh merged 19 commits into
enviodev:mainfrom
pavlovdog:main
Feb 12, 2025
Merged

Change the public schema name with ENV vars#445
DZakh merged 19 commits into
enviodev:mainfrom
pavlovdog:main

Conversation

@pavlovdog

Copy link
Copy Markdown
Contributor

No description provided.

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I left one comment regarding tests. Also, I remember there were some queries in the Rust code. Could you double check them as well 👌


describe("Entity History Codegen", () => {
it("Creates a postgres insert function", () => {
let expected = `CREATE OR REPLACE FUNCTION "insert_TestEntity_history"(history_row "public"."TestEntity_history", should_copy_current_entity BOOLEAN)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the expected as a plain string

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree here, the tests should not have dynamic environment values for assertions

@pavlovdog pavlovdog force-pushed the main branch 3 times, most recently from 70bcb85 to e83badf Compare February 5, 2025 12:26

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good 👍 This is an amazing work and cool to see little improvements not related to the main problem. I left one comment regarding using EnvState in db.rs. Also, you're our first external contributor, so I need to share our Contributor License Agreement (CLA) with you, since we created it after you've started working on the PR 😅

I asked @JonoPrest to make a final review. I'll merge it and create a release after he approves 💪

Comment thread codegenerator/cli/src/persisted_state/db.rs Outdated
Comment thread codegenerator/cli/templates/static/codegen/src/db/Migrations.res
@DZakh DZakh requested a review from JonoPrest February 10, 2025 11:22
Comment thread codegenerator/cli/templates/static/codegen/src/db/DbFunctions.res Outdated
Comment thread codegenerator/cli/templates/static/codegen/src/db/DbFunctions.res Outdated
Comment thread codegenerator/cli/src/persisted_state/db.rs Outdated
Comment thread codegenerator/cli/src/persisted_state/db.rs Outdated
Comment thread codegenerator/cli/templates/static/codegen/src/db/Migrations.res Outdated
Comment thread codegenerator/cli/templates/static/codegen/src/db/Migrations.res Outdated

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pavlovdog, thanks so much for the contribution 🔥

Before merging we just need to sanitise the the schema name on raw query strings to handle mixed casing. And it would be good to see a test that uses an alt schema name to validate everything works as expected. Perhaps it's just worth duplicating one of the integration tests where an alterenative schema name is set before start up.

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving since my comments are not blocking for merge, it's already an improvement 👍🏼

pavlovdog and others added 4 commits February 11, 2025 16:51
Co-authored-by: Jono Prest <65739024+JonoPrest@users.noreply.github.com>
@pavlovdog

Copy link
Copy Markdown
Contributor Author

Hey @JonoPrest, thanks so much for your review! I'm happy to be your first contributor :) I've updated the code with your comments, test_codegen is passing.

I'm happy to cover this with a test, do you think I can copy-paste integration-raw-events-test.ts with public. replaced with custom.? I guess I would need to put it into a separate folder, like scenarios/test_custom_pg_schema, and add it into the CI so it is executed with ENVIO_PG_PUBLIC_SCHEMA=custom. What do you think?

@JonoPrest

Copy link
Copy Markdown
Collaborator

Hey @JonoPrest, thanks so much for your review! I'm happy to be your first contributor :) I've updated the code with your comments, test_codegen is passing.

I'm happy to cover this with a test, do you think I can copy-paste integration-raw-events-test.ts with public. replaced with custom.? I guess I would need to put it into a separate folder, like scenarios/test_custom_pg_schema, and add it into the CI so it is executed with ENVIO_PG_PUBLIC_SCHEMA=custom. What do you think?

Awesome, I think it can be as simple as duplicating this test in the integration test script

export TEMPLATE="test_indexers/dynamic_contracts"
export TEST_FILE="DynamicContracts"
CONFIG_FILE="config-dynamic-contracts.yaml" SHOULD_FAIL=false TEST_RESTART=true ./tests/testIndexerExits.sh
with a schema set in the env. Lets do it in a separate PR

@DZakh DZakh merged commit e953d71 into enviodev:main Feb 12, 2025
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.

3 participants