Skip to content

Tulup-404/s26-databases

 
 

Repository files navigation

Create a .env file

  1. Copy the .env.example file to the .env file:

    Run using the terminal:

    cp .env.example .env
    

    If you use PowerShell, run:

    copy .env.example .env
    
  2. Edit the .env file as necessary.

You should use db from .zip file

Open it and add to root direstory

Remove old containers

  1. Open the lab directory.

  2. Stop containers:

    Run using the terminal:

    docker compose stop
    
  3. Remove containers:

    Run using the terminal:

    docker compose rm
    

Run containers

  1. Run Postgres and pgAdmin containers:

    Run using the terminal:

    docker compose up
    
  2. Wait 2-3 minutes until pgAdmin starts.

  3. If you need to run other commands use any of these options:

    • Option 1: press d in the terminal where you run the containers.
    • Option 2:
      1. Open a new terminal.
      2. Navigate there to the s26-databases/lab-4 directory.

SQL auto migration on startup

  • File demo-medium-en-20170815.sql is mounted into Postgres init directory and is applied automatically as an initial migration.

  • It runs only when database volume is empty (first initialization), because this is how postgres entrypoint works.

  • To re-apply this SQL from scratch:

    docker compose down -v
    docker compose up -d
    

Connect pgAdmin to the database

  1. Open pgAdmin in a browser: go to http://localhost:45050.
  2. Log in:
    1. Login: the value of PGADMIN_DEFAULT_EMAIL defined in .env
    2. Password: the value of PGADMIN_DEFAULT_PASSWORD defined in .env.
  3. Click Add New Server.
  4. In General, set:
    • Name: postgres
  5. In Connection, set:
    • Host name/address: postgres (service name created by Docker)
    • Port: 5432 (the value of POSTGRES_PORT defined in .env)
    • Maintenance database: postgres (the value of POSTGRES_DB defined in .env)
    • Username: postgres (the value of POSTGRES_USER defined in .env)
    • Password: postgres (the value of POSTGRES_PASSWORD defined in .env)
  6. Click Save.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Makefile 100.0%