pressly / goose

A database migration tool. Supports SQL migrations and Go functions.

Home Page:http://pressly.github.io/goose/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to create postgres schema.

mrVin99 opened this issue · comments

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?

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

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.