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

Database issues when following docker install guide #21

Closed
darkpixel opened this issue Jul 21, 2020 · 8 comments
Closed

Database issues when following docker install guide #21

darkpixel opened this issue Jul 21, 2020 · 8 comments

Comments

@darkpixel
Copy link

The documentation says to run:

docker-compose -p citadel up -d
docker-compose -p citadel -f docker-compose.yml -f docker-compose.migrate.yml run --rm migrate

I ran those with no apparent issues.

The documentation then says:

If you visit http://localhost:3333, you will get redirected to the installation screen so that you can create the first system user.

When I surf to the page, it brings me to a login screen, not a setup screen to create the first user.
This is printed in the log:

postgres_1  | 2020-07-21 20:34:14.735 UTC [27] ERROR:  relation "system_options" does not exist at character 59
postgres_1  | 2020-07-21 20:34:14.735 UTC [27] STATEMENT:  -- name: GetSystemOptionByKey :one
postgres_1  | 	SELECT key, value FROM system_options WHERE key = $1
postgres_1  | 	
web_1       | time="21-07-2020 20:34:14" level=error msg="get system option" error="pq: relation \"system_options\" does not exist"
postgres_1  | 2020-07-21 20:34:14.804 UTC [27] ERROR:  relation "system_options" does not exist at character 59
postgres_1  | 2020-07-21 20:34:14.804 UTC [27] STATEMENT:  -- name: GetSystemOptionByKey :one
postgres_1  | 	SELECT key, value FROM system_options WHERE key = $1
postgres_1  | 	
web_1       | time="21-07-2020 20:34:14" level=error msg="get system option" error="pq: relation \"system_options\" does not exist"
postgres_1  | 2020-07-21 20:34:28.013 UTC [27] ERROR:  relation "user_account" does not exist at character 174
postgres_1  | 2020-07-21 20:34:28.013 UTC [27] STATEMENT:  -- name: GetUserAccountByUsername :one
postgres_1  | 	SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code FROM user_account WHERE username = $1
postgres_1  | 	

Trying to sign in with admin/admin produces this:

web_1       | time="21-07-2020 20:34:28" level=warning msg="user account not found" username=admin

I've tried stopping the docker containers, removing them, and removing the volumes and then running it again with no luck.

@tionis
Copy link

tionis commented Jul 21, 2020

I can reproduce this as of 70802ff.

@JordanKnott
Copy link
Owner

JordanKnott commented Jul 22, 2020

It sounds like the migration step didn't get run successfuly- can you re-run docker-compose -p citadel -f docker-compose.yml -f docker-compose.migrate.yml run --rm migrate and send me the log output from that command?

(after running the above command, try revisiting http://localhost:3333/ to see if the setup screen get's shown)

@darkpixel
Copy link
Author

darkpixel commented Jul 22, 2020

$ docker-compose -p citadel -f docker-compose.yml -f docker-compose.migrate.yml run --rm migrate
Starting citadel_postgres_1 ... done
Error: no change
Usage:
  citadel migrate [flags]

Flags:
  -h, --help   help for migrate

$ 

@darkpixel
Copy link
Author

darkpixel commented Jul 22, 2020

Strange. Even though it says "no change", if I stop and re-start the docker-compose -p citadel up command, it now works correctly.

EDIT: And I had run the migration command multiple times before. I think it maybe just needed docker-compose to go down and up again?

@JordanKnott
Copy link
Owner

When you re-did the docker-compose -p citadel up command, did it rebuild the image or did it just use an existing one (if there was only a couple lines of output, it used an existing image)?

That's very odd. The no change means that the migrations were run.

@darkpixel
Copy link
Author

I hadn't used citadel before.
So I ran the docker-compose up command and it downloaded and built the image. After it was up, I ran the migration and didn't receive any errors. When I surfed to the site, it showed a login page instead of the setup page, so I ran migrations again. It said there weren't any migrations.

I tried blowing away the docker images and the associated volumes and doing it again. That's when I turned in the ticket. But this time, after it said there were no migrations, I stopped docker-compose and started it again and it worked.

I'll have to see if I can duplicate it after removing the images and volumes again.

@JordanKnott
Copy link
Owner

Well that's just strange - let me know if you're able to duplicate it and the steps you did!

For now I'm going to go ahead and close this as I wasn't able to get it to do the same on my end.

@JadeVane
Copy link

Same here. I got a login page when visited http://localhost:3333 after running taskcafe for the first time, so I am not able to create the first user now.

BTW, I build taskcate from source code, and run the command below to try to get it work

# login to postgresql
sudo -u postgres psql

# create database
CREATE DATABASE taskcafe OWNER taskcafe;
GRANT ALL PRIVILEGES ON DATABASE taskcafe TO taskcafe;

# fix a bug
sudo -u postgres psql taskcafe -c 'CREATE EXTENSION "uuid-ossp";'

# run taskcafe
./taskcafe migrate --config config.toml 
./taskcafe web --config config.toml

the bug above means I will get the error message below when I run ./taskcafe migrate --config config.toml follow the documents

Error: migration failed: permission denied to create extension "uuid-ossp" in line 0: CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

CREATE TABLE refresh_token (
  token_id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
  user_id uuid NOT NULL,
  created_at timestamptz NOT NULL,
  expires_at timestamptz NOT NULL
);
 (details: pq: permission denied to create extension "uuid-ossp")

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