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

Unable to create postgres schema. #688

Closed
mrVin99 opened this issue Jan 28, 2024 · 2 comments
Closed

Unable to create postgres schema. #688

mrVin99 opened this issue Jan 28, 2024 · 2 comments

Comments

@mrVin99
Copy link

mrVin99 commented Jan 28, 2024

I am encountering an issue while attempting to create a schema using Goose migrations. I added the "CREATE SCHEMA schema_name" command in the Goose migration file, the script ran successfully and created the goose_db_version table. However, the schemas are not being created.
Examples i tried:
-- +goose Up -- +goose StatementBegin CREATE SCHEMA schema_name_example; -- +goose StatementEnd

-- +goose Up CREATE SCHEMA schema_name_example;

Is this the expected behaviour or i'm doing something wrong?

@mfridman
Copy link
Collaborator

What error are you receiving?

Not sure if it is a copying error, but you need to break up your statements, otherwise it's considered one long comment. I tried the following:

-- +goose Up

CREATE SCHEMA IF NOT EXISTS test_schema;

And it applied the migration, goose_db_version:

id version_id is_applied tstamp
1 0 t 2024-01-29 14:28:23.765292
2 1 t 2024-01-29 14:28:23.782379

And created the "test_schema":

SELECT
	*
FROM
	pg_catalog.pg_namespace;

Returns:

oid nspname nspowner nspacl
99 pg_toast 10
11 pg_catalog 10 {postgres=UC/postgres,=U/postgres}
2200 public 10 {postgres=UC/postgres,=UC/postgres}
13403 information_schema 10 {postgres=UC/postgres,=U/postgres}
16393 test_schema 10

@mrVin99
Copy link
Author

mrVin99 commented Jan 29, 2024

Indeed, you're right. My apologies. The issue lies with IntelliJ IDEA in this case. I'm using their database console to view my tables, etc., and it's not displaying them when I create the schema via Goose. However, it shows up when I create it manually. Thank you for the response, and I apologize for the seemingly simple question.

@mrVin99 mrVin99 closed this as completed Jan 29, 2024
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

No branches or pull requests

2 participants