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

Migrations failing to run #25

Closed
heromiyo opened this issue Jun 5, 2021 · 6 comments
Closed

Migrations failing to run #25

heromiyo opened this issue Jun 5, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@heromiyo
Copy link

heromiyo commented Jun 5, 2021

Bug report

Describe the bug

Migrations are failing to run when starting the storage server

A clear and concise description of what the bug is.

supa-storage@0.0.1 restart:db
docker-compose --project-dir . -f src/test/db/docker-compose.yml down && docker-compose --project-dir . -f src/test/db/docker-compose.yml up -d && sleep 5 && npm run migration:run

Stopping storage-api_rest_1 ... done
Stopping storage-api_db_1 ... done
Removing storage-api_rest_1 ... done
Removing storage-api_db_1 ... done
Removing network storage-api_default
Creating network "storage-api_default" with the default driver
Creating storage-api_db_1 ... done
Creating storage-api_rest_1 ... done

supa-storage@0.0.1 migration:run
ts-node-dev ./src/scripts/migrate-call.ts

[INFO] 17:56:58 ts-node-dev ver. 1.1.6 (using ts-node ver. 9.1.1, typescript ver. 4.2.3)
running migrations
(node:2616) UnhandledPromiseRejectionWarning: Error: Migration failed. Reason: An error occurred running 'create-migrations-table'. Rolled back this migration. No further migrations were run. Reason: no schema
has been selected to create in
at D:\PROJECTS\storage-api\node_modules\postgres-migrations\dist\migrate.js:63:27
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at D:\PROJECTS\storage-api\node_modules\postgres-migrations\dist\with-lock.js:25:28
(Use node --trace-warnings ... to show where the warning was created)
(node:2616) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not han
dled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection
id: 1)
(node:2616) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. clone supabase/storage-api
  2. cd storage-api
  3. npm run restart:db
    4 migrations failing to run

Expected behavior

A clear and concise description of what you expected to happen.

Server should run

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: [e.g. 6.0.2]
  • Version of Node.js: [e.g. 10.10.0]

Additional context

Add any other context about the problem here.

@heromiyo heromiyo added the bug Something isn't working label Jun 5, 2021
@inian
Copy link
Member

inian commented Jun 7, 2021

Hi @heromiyo, this happens if you don't have the search path set correctly. Can you ensure that the .env.sample file has been copied to .env and there is a PGOPTIONS in your .env file?

@heromiyo
Copy link
Author

heromiyo commented Jun 8, 2021

Thanks, that was the issue

@heromiyo heromiyo closed this as completed Jun 8, 2021
@difelice
Copy link

difelice commented Jun 15, 2021

I'm having similar issue running a container from supabase/storage-api, migrations worked fine, and PGOPTIONS is in the final env list, but for some reason it's still requesting on the public schema:

Docker Compose logs:

storage_1  | running migrations
storage_1  | finished migrations
storage_1  | [1623760631182] INFO (8 on 66b95fdc2426): Server listening at http://0.0.0.0:5000
storage_1  | Server listening at http://0.0.0.0:5000
rest_1      | 172.22.0.9 - - [15/Jun/2021:13:10:50 +0000] "GET /buckets?select=id%2Cname%2Cpublic%2Cowner%2Ccreated_at%2Cupdated_at HTTP/1.1" 404 - "" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)
kong_1      | 172.22.0.6 - - [15/Jun/2021:13:10:50 +0000] "GET /storage/v1/bucket HTTP/1.0" 400 88 "-" "PostmanRuntime/7.28.0"
storage_1   | [1623762650441] ERROR (1 on 076642b861e0): error bucket
storage_1   |       "hint": null,
storage_1   |       "details": null,
storage_1   |       "code": "42P01",
storage_1   |       "message": "relation \"public.buckets\" does not exist"
storage_1   |     }
$ docker compose exec storage /bin/bash -c 'env | grep PGO'
PGOPTIONS=-c search_path=storage

Database looks OK:

$ PGOPTIONS="-c search_path=storage" ./psql.sh 
Null display is "💩".
psql (12.6, server 12.3 (Debian 12.3-1.pgdg100+1))
Type "help" for help.

postgres=# \d
            List of relations
 Schema  |    Name    | Type  |  Owner   
---------+------------+-------+----------
 storage | buckets    | table | postgres
 storage | migrations | table | postgres
 storage | objects    | table | postgres
(3 rows)

Thanks.

@inian
Copy link
Member

inian commented Jun 15, 2021

Hi @difelice, can you check if postgrest has storage in PGRST_DB_SCHEMA like here

@difelice
Copy link

difelice commented Jun 15, 2021

Hi @difelice, can you check if postgrest has storage in PGRST_DB_SCHEMA like here

Thank you! That was it. I missed completely from the supabase PR. 🤗

@inian
Copy link
Member

inian commented Jun 15, 2021

Glad its sorted :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants