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

Added schema creation (postgres) if needed on first migration #4000

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

spanyukov
Copy link

fix a problem with first migration when you don't have schema yet.
Before you had a bug like this:
error: create table "config"."knex_migrations" ("id" serial primary key, "name" varchar(255), "batch" integer, "migration_time" timestamptz) - schema "config" does not exist

fix a problem with first migration when you don't have schema yet
@ike18t
Copy link

ike18t commented Oct 13, 2020

I'd love to have this functionality as well. Unfortunately the commit broke the build but a conditional call of createSchemaIfNotExists based on if a schemaName exists should resolve the issue.

@spanyukov
Copy link
Author

I'd love to have this functionality as well. Unfortunately the commit broke the build but a conditional call of createSchemaIfNotExists based on if a schemaName exists should resolve the issue.

Its working only with Postgres yet.. I will fix it and make PR again.

@ike18t
Copy link

ike18t commented Nov 3, 2020

@spanyukov Do you think you'll have time to update this PR? I don't mind opening a new PR if not.

condtitional check for createSchemaIfNotExists
@spanyukov
Copy link
Author

@spanyukov Do you think you'll have time to update this PR? I don't mind opening a new PR if not.

I added condition.

@ike18t
Copy link

ike18t commented Nov 4, 2020

Your changes unfortunately don't pass CI. You are probably better off appending the createSchemaIfNotExists to

? trxOrKnex.schema.withSchema(schemaName)

Then the change only needs to happen in one place and that place is already "schema aware".

Also there is docker-compose file if you want to run tests locally to verify your changes.

create schema in schema builder getter
@spanyukov
Copy link
Author

Your changes unfortunately don't pass CI. You are probably better off appending the createSchemaIfNotExists to

? trxOrKnex.schema.withSchema(schemaName)

Then the change only needs to happen in one place and that place is already "schema aware".
Also there is docker-compose file if you want to run tests locally to verify your changes.

thanks! I put this code to schema builder getter as you described.

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.

None yet

2 participants