I was recently trying to develop some Known schema changes, and had the need to start kicking about Known in a Postgres environment.
Known supports Postgres out of the box, but I admit it’s a less trodden path. I don’t routinely use Postgres (I tend to favour mysql/mariadb, purely because that’s what I’m used to), and it’s usually a pain to switch environments.
I previously built a docker development environment, so I took the obvious (and as it turned out trivial) next step to build a Postgres version.
- Download and install docker
- Add this docker image to known using composer
composer require mapkyca/mapkyca-known-docker-postgres --dev
This will create a docker environment in
- Point your browser at
localhost:8089 and install in the usual way
» Visit the project on Github...
The other week, I wrote about introducing SQLite support to Known.
Seemingly, I was on a role, and because a client asked me to look in to Postgres support for a separate project, I thought I’d have a crack at implementing support for Known, which I’m glad has been merged in.
This turns out to have been useful to a bunch of folk, for which I am glad.
Postgres support is still in Beta, and MySQL is still the recommended database engine, so currently installation is a bit of a manual process.
First, you need to make sure you’ve got Postgres support built in to PHP:
apt-get install php5-pgsql
Then, you need to modify your
database = 'Postgres'
dbname = 'dbname'
dbpass = 'password'
dbuser = 'username'
dbhost = 'hostname'
filesystem = 'local'
uploadpath = '/path/to/upload_directory/
Once you’ve done that, you need to install the schema, which currently needs to be done from the command line.
psql -c 'create database <dbname>;' -U <dbuser>
psql -U <dbuser> -d <dbname> -a -f schemas/postgres/postgres.sql
Assuming you got no errors, you should now be good to go!