PostgreSQL

PostgreSQL is an advanced open source database server. You can easily add it to your Lando app by adding an entry to the services key in your app's .lando.yml.

Supported versions

Be Careful Switching Database Type or Version

You should be careful switching database types or versions as the underlying database files between these things may not be compatible. Ignoring this warning can cause your database service to not start correctly!!!

You can read more about this here

Example

# The name of the app
name: postgres

# Give me http://postgres.lndo.site and https://postgres.lndo.site
proxy:
  html:
    - postgres.lndo.site

# Service configuration
services:

  # Set up a basic webserver running the latest nginx with ssl turned on
  html:
    webroot: www
    type: nginx
    ssl: true

  # Spin up a postgres container called "tswift"
  tswift:

    # Use the latest version of postgres
    type: postgres

    # Optionally allow access to the database at localhost:3307
    # You will need to make sure port 3307 is open on your machine
    #
    # You can also set `portforward: true` to have Lando dynamically assign
    # a port. Unlike specifying an actual port setting this to true will give you
    # a different port every time you restart your app
    portforward: 5444

    # Optionally set the default db credentials
    creds:
      user: trouble
      password: trouble
      database: trouble

    # Optionally specify a postgres config file relative to the app root directory
    config:
      postgres: config/postgresql.conf

You will need to rebuild your app with lando rebuild to apply the changes to this file. You can check out the full code for this example over here.

Getting information

You can get connection and credential information about your database by running lando info from inside your app.

# Navigate to the app
cd /path/to/app

# Get info (app needs to be running to get this)
lando info

{
  "html": {
    "type": "nginx",
    "version": "latest",
    "urls": [
      "https://localhost:32811",
      "http://localhost:32812",
      "http://postgres.lndo.site",
      "https://postgres.lndo.site"
    ]
  },
  "tswift": {
    "type": "postgres",
    "version": "latest",
    "creds": {
      "user": "trouble",
      "password": "trouble",
      "database": "trouble"
    },
    "internal_connection": {
      "host": "tswift",
      "port": 5432
    },
    "external_connection": {
      "host": "localhost",
      "port": 5444
    }
  }
}

results matching ""

    No results matching ""