mirror of https://github.com/citusdata/citus.git
Add very basic infrastructure for schema upgrade scripts.
Citus' extension version now has a -$schemaversion appendix. When the schema is changed, a new schema version has to be added; changes to the same schema version several commits inside a single pull request are ok. Schema migration scripts between each schema version have to be added. To ensure upgrade scripts work correctly a new regression test ensures that all steps work. The extension scripts to-be-used for CREATE EXTENSION (i.e. not extension updates) are generated by concatenating citus.sql and the relevant migration scripts.pull/471/head
parent
5ffce3393a
commit
25f919576f
|
@ -5,8 +5,11 @@ citus_top_builddir = ../../..
|
||||||
|
|
||||||
MODULE_big = citus
|
MODULE_big = citus
|
||||||
EXTENSION = citus
|
EXTENSION = citus
|
||||||
EXTVERSION = 5.0
|
EXTVERSIONS = 5.0 5.0-1
|
||||||
DATA_built = $(EXTENSION)--$(EXTVERSION).sql
|
# All citus--*.sql files in the source directory
|
||||||
|
DATA = $(patsubst $(citus_abs_srcdir)/%.sql,%.sql,$(wildcard $(citus_abs_srcdir)/$(EXTENSION)--*--*.sql))
|
||||||
|
# Generated files for each version
|
||||||
|
DATA_built = $(foreach v,$(EXTVERSIONS),$(EXTENSION)--$(v).sql)
|
||||||
SCRIPTS = ../../bin/scripts/copy_to_distributed_table
|
SCRIPTS = ../../bin/scripts/copy_to_distributed_table
|
||||||
|
|
||||||
# directories with source files
|
# directories with source files
|
||||||
|
@ -20,8 +23,11 @@ OBJS += \
|
||||||
# be explicit about the default target
|
# be explicit about the default target
|
||||||
all:
|
all:
|
||||||
|
|
||||||
# define build process for latest install file
|
# generate each version's file installation file by concatenating
|
||||||
$(EXTENSION)--$(EXTVERSION).sql: $(EXTENSION).sql
|
# previous upgrade scripts
|
||||||
|
$(EXTENSION)--5.0.sql: $(EXTENSION).sql
|
||||||
|
cat $^ > $@
|
||||||
|
$(EXTENSION)--5.0-1.sql: $(EXTENSION)--5.0.sql $(EXTENSION)--5.0--5.0-1.sql
|
||||||
cat $^ > $@
|
cat $^ > $@
|
||||||
|
|
||||||
NO_PGXS = 1
|
NO_PGXS = 1
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
/* citus--5.0--5.0-1.sql */
|
||||||
|
|
||||||
|
-- Currently nothing to do here
|
|
@ -1,6 +1,6 @@
|
||||||
# Citus extension
|
# Citus extension
|
||||||
comment = 'Citus distributed database'
|
comment = 'Citus distributed database'
|
||||||
default_version = '5.0'
|
default_version = '5.0-1'
|
||||||
module_pathname = '$libdir/citus'
|
module_pathname = '$libdir/citus'
|
||||||
relocatable = false
|
relocatable = false
|
||||||
schema = pg_catalog
|
schema = pg_catalog
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
--
|
||||||
|
-- MULTI_EXTENSION
|
||||||
|
--
|
||||||
|
-- Tests around extension creation / upgrades
|
||||||
|
--
|
||||||
|
-- It'd be nice to script generation of this file, but alas, that's
|
||||||
|
-- not done yet.
|
||||||
|
-- DROP EXTENSION pre-created by the regression suite
|
||||||
|
DROP EXTENSION citus;
|
||||||
|
\c
|
||||||
|
-- Create extension in oldest version, test every upgrade step
|
||||||
|
CREATE EXTENSION citus VERSION '5.0';
|
||||||
|
ALTER EXTENSION citus UPDATE TO '5.0-1';
|
||||||
|
-- drop extension an re-create in newest version
|
||||||
|
DROP EXTENSION citus;
|
||||||
|
\c
|
||||||
|
CREATE EXTENSION citus;
|
|
@ -11,6 +11,7 @@
|
||||||
# ---
|
# ---
|
||||||
# Tests around schema changes, these are run first, so there's no preexisting objects.
|
# Tests around schema changes, these are run first, so there's no preexisting objects.
|
||||||
# ---
|
# ---
|
||||||
|
test: multi_extension
|
||||||
test: multi_table_ddl
|
test: multi_table_ddl
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
--
|
||||||
|
-- MULTI_EXTENSION
|
||||||
|
--
|
||||||
|
-- Tests around extension creation / upgrades
|
||||||
|
--
|
||||||
|
-- It'd be nice to script generation of this file, but alas, that's
|
||||||
|
-- not done yet.
|
||||||
|
|
||||||
|
-- DROP EXTENSION pre-created by the regression suite
|
||||||
|
DROP EXTENSION citus;
|
||||||
|
\c
|
||||||
|
|
||||||
|
-- Create extension in oldest version, test every upgrade step
|
||||||
|
CREATE EXTENSION citus VERSION '5.0';
|
||||||
|
ALTER EXTENSION citus UPDATE TO '5.0-1';
|
||||||
|
|
||||||
|
-- drop extension an re-create in newest version
|
||||||
|
DROP EXTENSION citus;
|
||||||
|
\c
|
||||||
|
CREATE EXTENSION citus;
|
Loading…
Reference in New Issue