/* * As of 2022-10-19 Shinobi will create the tables during the startup process. * Only a blank database needs to exist with access provided to the sql user. * * * PostgresSQL rewrite of framework.sql - dave@dream-tech.com * Placed into open source, no license required here unless you want one, licenses and lawyers * are the primary bane of good software development. :) * * Trigger code lifted from stack overflow here: * https://stackoverflow.com/questions/9556474/how-do-i-automatically-update-a-timestamp-in-postgresql * * Summary of changes: * a) Removed mysql cruft and comments, no need for 'use' * b) Removed create database statement (I can put one back but usually I create dbs using postgres command line tools: * e.g. 'createdb foo') * c) Removed all cases of int(\d+) and replaced with just int, postgres does not support those * d) Removed ENGINE=InnoDB * e) Removed default charset statements, Postgresql automatically supports 4-byte UTF8 at database createion * f) Removed backtick quotes and added double quotes * g) All timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP replaced with triggers * and the ON UPDATE portion removed as postgres doesn't support this sadly * h) tinytext/longtest is changed to just text, generally postgres does a good job of managing arbitrary text columns * i) Enums created the Postgres way by creating a type * * Here's my DB create flow: * 1) become the account that controls pgsql (pgsql superuser) * 2) from that shell prompt, say: * createuser -p shinobi * Enter a secure password after this, twice. * 3) from same shell prompt say: * createdb --owner shinobi --encoding='utf-8' shinobi * 4) now from same shell prompt you can do * psql shinobi