Skip to content

Initial schema setup file not being ran #345

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

Closed
Syntaf opened this issue Sep 23, 2017 · 2 comments
Closed

Initial schema setup file not being ran #345

Syntaf opened this issue Sep 23, 2017 · 2 comments

Comments

@Syntaf
Copy link

Syntaf commented Sep 23, 2017

Excuse my lack of knowledge with docker, but I can't seem to figure out why my initial schema isn't being ran. My docker-compose looks like:

version: '2'

services:
    boilerplatebackend:
        ...

        depends_on:
            - postgres

        environment:
            DATABASE_URL: ...

        ports:
          - "8080:8080"
    postgres:
        image: postgres
        environment:
            POSTGRES_USER: smashggextadmin
            POSTGRES_DB: smashggext
        build: ./backend/database

then inside ./backend/database I have

FROM postgres
COPY ./initial_schema.sql /docker-entrypoint-initdb.d/

where initial_schema.sql =
CREATE TABLE links(channelid INT NOT NULL PRIMARY KEY, link VARCHAR(255) NOT NULL)

Everything seems to get up and running, but the links table is never created. Am I doing something blatantly wrong here? Thanks a bunch for any help!

@yosifkit
Copy link
Member

This might help explain how the volumes get saved when using compose: #203 (comment). The short answer is that the initdb.d files are only run when the database files have not been created.

@Syntaf
Copy link
Author

Syntaf commented Sep 27, 2017

Thanks @yosifkit , I found that removing the existing volume and building from scratch worked.

@Syntaf Syntaf closed this as completed Sep 27, 2017
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

2 participants