Starting from scratch

Let's consider the sample database used throughout this book and make an extension called pg11ssp. The first version of the extension, version 1.0, will define the data structure (the tables and constraints) and a few functions. Let's start with the script file, which is partially shown in Listing 3. As you can see, it is a plain SQL set of statements:

CREATE TABLE IF NOT EXISTS files ( ... );
CREATE TABLE IF NOT EXISTS tags( ... );
CREATE TABLE IF NOT EXISTS j_files_tags ( ... );
Listing 3: The script file pg11ssp–1.0.sql

Let's now consider the control file. This must set default_version to the smallest version number available, which, in this case, is 1.0. Moreover, to make things simpler, we can have the script file ...

Get PostgreSQL 11 Server Side Programming Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.