Database error when installing TTS : relation "users" does not exist

Hello to all kind strangers out there !

I am trying to install TTS as localhost on my Windows 10 computer.
I was following the tutorial video : Installing The Things Stack on Localhost - YouTube
(I used OpenSSL for the certificates, then ditched https for http)
It is basically this tutorial : Running The Things Stack | The Things Stack for LoRaWAN

Everything was going well until I had a problem when launching this command:
docker-compose run --rm stack is-db create-admin-user --id admin --email my.email@email.com

I tried reinstalling everything, tried looking everywhere for references to this error without success…
The console log is down there:

C:\Users\shine\the-things-stack>docker-compose pull
[+] Running 3/3
 - postgres Pulled                                                                                                 2.9s
 - redis Pulled                                                                                                    3.0s
 - stack Pulled                                                                                                    2.5s

C:\Users\shine\the-things-stack>docker-compose run --rm stack is-db init
[+] Running 2/1
 - Container the-things-stack-postgres-1  Running                                                                  0.0s
 - Container the-things-stack-redis-1     Running                                                                  0.0s
init command deprecated, use migrate instead

C:\Users\shine\the-things-stack>docker-compose run --rm stack is-db create-admin-user --id admin --email my.email@email.com
[+] Running 2/0
 - Container the-things-stack-redis-1     Running                                                                  0.0s
 - Container the-things-stack-postgres-1  Running                                                                  0.0s
INFO    Connecting to Identity Server database...
Please enter user password:*************
Please repeat user password:*************
INFO    Creating user...
ERROR   Database error  {"code": "undefined_table", "error": "error:pkg/identityserver/gormstore:database (database error)", "error_cause": "pq: relation \"users\" does not exist", "source": "user_store.go:154"}
go.thethings.network/lorawan-stack/v3/pkg/log.(*zapHandler).HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/zap_handler.go:84
go.thethings.network/lorawan-stack/v3/pkg/log.(*Logger).Use.func1
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/logger.go:55
go.thethings.network/lorawan-stack/v3/pkg/log.HandlerFunc.HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/handler.go:38
go.thethings.network/lorawan-stack/v3/pkg/log/middleware/observability.(*observability).Wrap.func1
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/middleware/observability/observability.go:86
go.thethings.network/lorawan-stack/v3/pkg/log.HandlerFunc.HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/handler.go:38
go.thethings.network/lorawan-stack/v3/pkg/log.(*Logger).commit
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/logger.go:75
go.thethings.network/lorawan-stack/v3/pkg/log.(*entry).commit
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/entry.go:69
go.thethings.network/lorawan-stack/v3/pkg/log.(*entry).Error
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/entry.go:94
go.thethings.network/lorawan-stack/v3/pkg/identityserver/gormstore.logger.Print
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/identityserver/gormstore/store.go:422
github.com/jinzhu/gorm.(*DB).print
        /home/runner/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/main.go:873
ERROR   Database error  {"code": "undefined_table", "error": "error:pkg/identityserver/gormstore:database (database error)", "error_cause": "pq: relation \"users\" does not exist", "source": "store.go:102"}
go.thethings.network/lorawan-stack/v3/pkg/log.(*zapHandler).HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/zap_handler.go:84
go.thethings.network/lorawan-stack/v3/pkg/log.(*Logger).Use.func1
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/logger.go:55
go.thethings.network/lorawan-stack/v3/pkg/log.HandlerFunc.HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/handler.go:38
go.thethings.network/lorawan-stack/v3/pkg/log/middleware/observability.(*observability).Wrap.func1
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/middleware/observability/observability.go:86
go.thethings.network/lorawan-stack/v3/pkg/log.HandlerFunc.HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/handler.go:38
go.thethings.network/lorawan-stack/v3/pkg/log.(*Logger).commit
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/logger.go:75
go.thethings.network/lorawan-stack/v3/pkg/log.(*entry).commit
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/entry.go:69
go.thethings.network/lorawan-stack/v3/pkg/log.(*entry).Error
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/entry.go:94
go.thethings.network/lorawan-stack/v3/pkg/identityserver/gormstore.logger.Print
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/identityserver/gormstore/store.go:422
github.com/jinzhu/gorm.(*DB).print
        /home/runner/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/main.go:873
ERROR   Database error  {"code": "undefined_table", "error": "error:pkg/identityserver/gormstore:database (database error)", "error_cause": "pq: relation \"users\" does not exist", "source": "store.go:102"}
go.thethings.network/lorawan-stack/v3/pkg/log.(*zapHandler).HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/zap_handler.go:84
go.thethings.network/lorawan-stack/v3/pkg/log.(*Logger).Use.func1
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/logger.go:55
go.thethings.network/lorawan-stack/v3/pkg/log.HandlerFunc.HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/handler.go:38
go.thethings.network/lorawan-stack/v3/pkg/log/middleware/observability.(*observability).Wrap.func1
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/middleware/observability/observability.go:86
go.thethings.network/lorawan-stack/v3/pkg/log.HandlerFunc.HandleLog
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/handler.go:38
go.thethings.network/lorawan-stack/v3/pkg/log.(*Logger).commit
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/logger.go:75
go.thethings.network/lorawan-stack/v3/pkg/log.(*entry).commit
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/entry.go:69
go.thethings.network/lorawan-stack/v3/pkg/log.(*entry).Error
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/log/entry.go:94
go.thethings.network/lorawan-stack/v3/pkg/identityserver/gormstore.logger.Print
        /home/runner/work/lorawan-stack/lorawan-stack/pkg/identityserver/gormstore/store.go:422
github.com/jinzhu/gorm.(*DB).print
        /home/runner/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/main.go:873
error:pkg/identityserver/gormstore:database (database error)
    code=undefined_table
    correlation_id=189044e2849e473c8137490d571a13a0
--- pq: relation "users" does not exist

Does anyone has had any similar issues? Does anyone has tips on how to solve the issue ?

My docker-compose.yml:

version: '3.7'
services:

  postgres:
    # In production, replace 'latest' with tag from https://hub.docker.com/_/postgres?tab=tags
    image: postgres:latest
    restart: unless-stopped
    environment:
      - POSTGRES_PASSWORD=root
      - POSTGRES_USER=root
      - POSTGRES_DB=ttn_lorawan
    volumes:
      - ${DEV_DATA_DIR:-.env/data}/postgres:/var/lib/postgresql/data
    ports:
      - "127.0.0.1:5432:5432"

  redis:
    # In production, replace 'latest' with tag from https://hub.docker.com/_/redis?tab=tags
    image: redis:latest
    command: redis-server --appendonly yes
    restart: unless-stopped
    volumes:
      - ${DEV_DATA_DIR:-.env/data}/redis:/data
    ports:
      - "127.0.0.1:6379:6379"

  stack:
    # In production, replace 'latest' with tag from https://hub.docker.com/r/thethingsnetwork/lorawan-stack/tags
    image: thethingsnetwork/lorawan-stack:latest
    entrypoint: ttn-lw-stack -c /config/ttn-lw-stack-docker.yml
    command: start
    restart: unless-stopped
    depends_on:
      - redis
      - postgres
    volumes:
      - ./blob:/srv/ttn-lorawan/public/blob
      - ./config/stack:/config:ro
      # If using Let's Encrypt:
      - ./acme:/var/lib/acme
    environment:
      TTN_LW_BLOB_LOCAL_DIRECTORY: /srv/ttn-lorawan/public/blob
      TTN_LW_REDIS_ADDRESS: redis:6379
      TTN_LW_IS_DATABASE_URI: postgres://root:root@postgres:5432/ttn_lorawan?sslmode=disable

    ports:
      # If deploying on a public server:
      - "80:1885"
      - "443:8885"
      - "1881:1881"
      - "8881:8881"
      - "1882:1882"
      - "8882:8882"
      - "1883:1883"
      - "8883:8883"
      - "1884:1884"
      - "8884:8884"
      - "1885:1885"
      - "8885:8885"
      - "1887:1887"
      - "8887:8887"
      - "1700:1700/udp"

#     # If using custom certificates:
#     secrets:
#       - ca.pem
#       - cert.pem
#       - key.pem

# # If using custom certificates:
# secrets:
#   ca.pem:
#     file: ./ca.pem
#   cert.pem:
#     file: ./cert.pem
#   key.pem:
#     file: ./key.pem

My ttn-lw-stack-docker.yml - NOTE that I’ve replaced my public IP address with 255.255 everywhere :

# Identity Server configuration
# Email configuration for "255.255.255.255"
is:
  email:
    sender-name: 'The Things Stack'
    sender-address: 'noreply@thethings.example.com'
    network:
      name: 'The Things Stack'
      console-url: 'http://255.255.255.255/console'
      identity-server-url: 'http://255.255.255.255/oauth'

    # If sending email with Sendgrid
    # provider: sendgrid
    # sendgrid:
    #   api-key: '...'              # enter Sendgrid API key

    # If sending email with SMTP
    # provider: smtp
    # smtp:
    #   address:  '...'             # enter SMTP server address
    #   username: '...'             # enter SMTP server username
    #   password: '...'             # enter SMTP server password

  # Web UI configuration for "255.255.255.255":
  oauth:
    ui:
      canonical-url: 'http://255.255.255.255/oauth'
      is:
        base-url: 'http://255.255.255.255/api/v3'

# HTTP server configuration
http:
  cookie:
    block-key: ''                # generate 32 bytes (openssl rand -hex 32)
    hash-key: ''                 # generate 64 bytes (openssl rand -hex 64)
  metrics:
    password: 'metrics'               # choose a password
  pprof:
    password: 'pprof'                 # choose a password

# # If using custom certificates:
# tls:
#   source: file
#   root-ca: /run/secrets/ca.pem
#   certificate: /run/secrets/cert.pem
#   key: /run/secrets/key.pem

# Let's encrypt for "255.255.255.255"
# tls:
#   source: 'acme'
#   acme:
#     dir: '/var/lib/acme'
#     email: 'you@255.255.255.255'
#     hosts: ['255.255.255.255']
#     default-host: '255.255.255.255'

# If Gateway Server enabled, defaults for "255.255.255.255":
gs:
  mqtt:
    public-address: '255.255.255.255:1882'
    public-tls-address: '255.255.255.255:8882'
  mqtt-v2:
    public-address: '255.255.255.255:1881'
    public-tls-address: '255.255.255.255:8881'

# If Gateway Configuration Server enabled, defaults for "255.255.255.255":
gcs:
  basic-station:
    default:
      lns-uri: 'wss://255.255.255.255:8887'
  the-things-gateway:
    default:
      mqtt-server: 'mqtts://255.255.255.255:8881'

# Web UI configuration for "255.255.255.255":
console:
  ui:
    canonical-url: 'http://255.255.255.255/console'
    is:
      base-url: 'http://255.255.255.255/api/v3'
    gs:
      base-url: 'http://255.255.255.255/api/v3'
    gcs:
      base-url: 'http://255.255.255.255/api/v3'
    ns:
      base-url: 'http://255.255.255.255/api/v3'
    as:
      base-url: 'http://255.255.255.255/api/v3'
    js:
      base-url: 'http://255.255.255.255/api/v3'
    qrg:
      base-url: 'http://255.255.255.255/api/v3'
    edtc:
      base-url: 'http://255.255.255.255/api/v3'

  oauth:
    authorize-url: 'http://255.255.255.255/oauth/authorize'
    token-url: 'http://255.255.255.255/oauth/token'
    logout-url: 'http://255.255.255.255/oauth/logout'
    client-id: 'console'
    client-secret: 'console'          # choose or generate a secret

# If Application Server enabled, defaults for "255.255.255.255":
as:
  mqtt:
    public-address: '255.255.255.255:1883'
    public-tls-address: '255.255.255.255:8883'
  webhooks:
    downlink:
      public-address: '255.255.255.255:1885/api/v3'

# If Device Claiming Server enabled, defaults for "255.255.255.255":
dcs:
  oauth:
    authorize-url: 'http://255.255.255.255/oauth/authorize'
    token-url: 'http://255.255.255.255/oauth/token'
    logout-url: 'http://255.255.255.255/oauth/logout'
    client-id: 'device-claiming'
    client-secret: 'device-claiming'          # choose or generate a secret
  ui:
    canonical-url: 'http://255.255.255.255/claim'
    as:
      base-url: 'http://255.255.255.255/api/v3'
    dcs:
      base-url: 'http://255.255.255.255/api/v3'
    is:
      base-url: 'http://255.255.255.255/api/v3'
    ns:
      base-url: 'http://255.255.255.255/api/v3'

Hi,

I remember having a similar problem.
Try to use “docker compose run --rm stack is-db migrate” instead of “docker-compose run --rm stack is-db init”.

Cordially,

Oh my god it worked. Thank you so much !!

I wish they would update the tutorial. Thank you !

Please post an issue in the GitHub repro so that it can be actioned. But FYI:

you had the answer all along!