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

Error when trying to start supergraph via docker-compose which generated using go. #76

Closed
asharabu opened this issue Jun 16, 2020 · 10 comments

Comments

@asharabu
Copy link

Hi,

I could able to generate files using the below commands,

go get github.com/dosco/super-graph
super-graph new testapp

After that, I tried to start services using docker-compose file,

ashar@testing:~/testapp$ docker logs -f testapp_testapp_api_1
restarting "./super-graph" when it changes (additional dirs: ./config)
INF roles_query not defined: attribute based access control disabled
ERR failed to initialize Super Graph: error fetching version: failed to connect to host=db user=postgres database=testapp_development: server error (FATAL: database "testapp_development" does not exist (SQLSTATE 3D000))

``

Upon searching I could able to see that the below command to fix the issue but getting some query issues also,

ashar@testing:~/testapp$ docker-compose run testapp_api ./super-graph db:setup
Creating network "testapp_default" with the default driver
Creating testapp_db_1 ... done
INF created database 'testapp_development'
INF 2020-06-16 10:15:01 executing 0_init.sql up
-- Write your migrate up statements here

CREATE TABLE public.users (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
full_name text,
email text UNIQUE NOT NULL CHECK (length(email) < 255),
created_at timestamptz NOT NULL NOT NULL DEFAULT NOW(),
updated_at timestamptz NOT NULL NOT NULL DEFAULT NOW()
);

ERR ERROR: syntax error at or near ";" (SQLSTATE 42601)

Please let me know what is wrong.

@dosco
Copy link
Owner

dosco commented Jun 16, 2020

Did you edit the migrations file or the postgres version?

@asharabu
Copy link
Author

Hi,
No, I have not edited it.

Postgres version seems 12, this was created when ran the go command.

@dosco
Copy link
Owner

dosco commented Jun 16, 2020

Try creating the app again from scratch. Not sure whats going on here it all seems right. Remember to kill all docker containers first.

go get github.com/dosco/super-graph
super-graph new <app_name>
cd <app_name>
docker-compose run api db:setup
docker-compose up

@asharabu
Copy link
Author

asharabu commented Jun 17, 2020

Hi,

Tried it again getting the same error, I have tried it in another machine also. The command you provided 4th one is missing

====
ashar@testing:/supergraph$ docker-compose run supergraph_api db:setup
Creating network "supergraph_default" with the default driver
Creating supergraph_db_1 ... done
./start.sh: line 12: db:setup: not found
ashar@testing:
/supergraph$ docker-compose run supergraph_api ./super-graph db:setup
Starting supergraph_db_1 ... done
INF created database 'supergraph_development'
INF 2020-06-17 04:06:22 executing 0_init.sql up
-- Write your migrate up statements here

CREATE TABLE public.users (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
full_name text,
email text UNIQUE NOT NULL CHECK (length(email) < 255),
created_at timestamptz NOT NULL NOT NULL DEFAULT NOW(),
updated_at timestamptz NOT NULL NOT NULL DEFAULT NOW()
);

ERR ERROR: syntax error at or near ";" (SQLSTATE 42601)

====

Are there environment variables to pass the database details on the docker version of the super-graph?. So that we can use super-graph docker version with our postgres database.

@dosco
Copy link
Owner

dosco commented Jun 17, 2020

Try deleting all your docker images and trying the commands again the missing command is due to changes in the latest docker image released today.

I tried this from scratch and it works perfectly for me the CREATE TABLE command is correct feel free to connect to Postgres with a client and manually copy past that same CREATE TABLE command it should work fine. The docker-compose file asks for version 12 of Postgres.

I feel might be some issue with your environment so it's interesting to understand why you're facing this issue.

@asharabu
Copy link
Author

Hi,

Sorry for saying that it didn't help me, I tried it from scratch but the same error, please see the complete process below,

ashar@testing:$ go get github.com/dosco/super-graph
ashar@testing:
$ super-graph new supersuper
INR created 'supersuper'
INR created 'supersuper/Dockerfile'
INR created 'supersuper/docker-compose.yml'
INR created 'supersuper/cloudbuild.yaml'
INR created 'supersuper/config'
INR created 'supersuper/config/dev.yml'
INR created 'supersuper/config/prod.yml'
INR created 'supersuper/config/seed.js'
INR created 'supersuper/config/allow.list'
INR created 'supersuper/config/migrations'
INR created 'supersuper/config/migrations/0_init.sql'
INR app 'supersuper' initialized
ashar@testing:$ cd supersuper/
ashar@testing:
/supersuper$ cat docker-compose.yml
version: '3.4'
services:

Postgres DB

db:
image: postgres:12
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"

supersuper_api:
image: dosco/super-graph:latest
environment:
GO_ENV: "development"
volumes:
- ./config:/config
ports:
- "8080:8080"
depends_on:
- db
ashar@testing:~/supersuper$ docker-compose run supersuper_api db:setup
Creating network "supersuper_default" with the default driver
Pulling db (postgres:12)...
12: Pulling from library/postgres
8559a31e96f4: Pull complete
04866763fec8: Pull complete
1705d51f48e5: Pull complete
e59f13162b50: Pull complete
f34bb6f66594: Pull complete
cbfb60b6801a: Pull complete
e8207269011b: Pull complete
89bccd0fcae0: Pull complete
d3be4c4d3a6e: Pull complete
6593b341f133: Pull complete
b63c7214eb05: Pull complete
a4594bc5ebc6: Pull complete
462172dd94a5: Pull complete
abac28c8c3a0: Pull complete
Digest: sha256:9ba6355d27ba9cd0acda1e28afaae4a5b7b2301bbbdc91794dcfca95ab08d2ef
Status: Downloaded newer image for postgres:12
Creating supersuper_db_1 ... done
Pulling supersuper_api (dosco/super-graph:latest)...
latest: Pulling from dosco/super-graph
df20fa9351a1: Pull complete
2ea3be8bbc20: Pull complete
590b2c94cd8b: Pull complete
3c3aec6d4920: Pull complete
ae078c6a7149: Pull complete
7833f6617136: Pull complete
f993aee7db44: Pull complete
13012480dade: Pull complete
Digest: sha256:fe691a267f1d407554ca736d71237e276a7c41bbbb7879a05c74ad788de7e582
Status: Downloaded newer image for dosco/super-graph:latest
INF created database 'supersuper_development'
INF 2020-06-17 06:32:00 executing 0_init.sql up
-- Write your migrate up statements here

CREATE TABLE public.users (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
full_name text,
email text UNIQUE NOT NULL CHECK (length(email) < 255),
created_at timestamptz NOT NULL NOT NULL DEFAULT NOW(),
updated_at timestamptz NOT NULL NOT NULL DEFAULT NOW()
);

ERR ERROR: syntax error at or near ";" (SQLSTATE 42601)

@aynik
Copy link

aynik commented Jun 26, 2020

I experienced the same error, in my case, the initial autogenerated migration looked like this:

-- Write your migrate up statements here

CREATE TABLE public.users (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  full_name  text,
  email      text UNIQUE NOT NULL CHECK (length(email) &lt; 255),
  created_at timestamptz NOT NULL NOT NULL DEFAULT NOW(),
  updated_at timestamptz NOT NULL NOT NULL DEFAULT NOW()
);

---- create above / drop below ----

-- Write your down migrate statements here. If this migration is irreversible
-- then delete the separator line above.

DROP TABLE public.users

Note the HTML entity &lt; instead of <. Correcting this fixed the issue.

@wttw
Copy link
Contributor

wttw commented Jul 1, 2020

I see the same issue here. "super-graph new app" generates config/seed.js and config/migrations/0_init.sql with HTML entities - "&lt;" instead of "<".

I've not dug too deeply, but I'd guess that internal/serv/cmd_new.go should be importing "text/template" rather than "html/template".

https://github.com/dosco/super-graph/blob/master/internal/serv/cmd_new.go#L5

I've put that in it's own issue: #95

@dosco
Copy link
Owner

dosco commented Jul 2, 2020

Thanks for reporting this the import must have been switched by the IDE I'll fix this.

@dosco
Copy link
Owner

dosco commented Jul 3, 2020

Fixed in a recent commit previous to 9c19db2

@dosco dosco closed this as completed Jul 3, 2020
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

4 participants