Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Add SQL migrations between schema ADDITIONs #134

Closed
alexanderdean opened this issue Feb 22, 2016 · 1 comment
Closed

Add SQL migrations between schema ADDITIONs #134

alexanderdean opened this issue Feb 22, 2016 · 1 comment
Assignees
Milestone

Comments

@alexanderdean
Copy link
Contributor

Consider the link_click: https://github.com/snowplow/iglu-central/tree/master/schemas/com.snowplowanalytics.snowplow/link_click/jsonschema

When running Schema Guru against this folder, Schema Guru should generate a file:

/sql/com.snowplowanalytics.snowplow/link-click/1-0-0/1-0-1.sql

The contents of this file should be:

-- WARNING: only apply this file to your database if the following SQL returns the expected:
--
-- select pg_catalog.obj_description(c.oid) from pg_catalog.pg_class c where c.relname = 'com_snowplowanalytics_snowplow_link_click_1';
--  obj_description
-- -----------------
--  iglu:com.snowplowanalytics.snowplow/link-click/jsonschema/1-0-0
-- (1 row)

BEGIN TRANSACTION;

  ALTER TABLE atomic.com_snowplowanalytics_snowplow_link_click_1
    ADD COLUMN "element_content" VARCHAR(4096) ENCODE LZO;

  COMMENT ON TABLE "atomic"."com_snowplowanalytics_snowplow_link_click_1" IS 'iglu:com.snowplowanalytics.snowplow/link-click/jsonschema/1-0-1';

END TRANSACTION;

In the case that com.acme/eg-schema/1-0-0, /1-0-1, /1-0-2 and /1-0-3 exist, the folder structure should look like this:

    /sql/com.acme/eg-schema/1-0-0/1-0-1.sql
    /sql/com.acme/eg-schema/1-0-0/1-0-2.sql
    /sql/com.acme/eg-schema/1-0-0/1-0-3.sql
    /sql/com.acme/eg-schema/1-0-1/1-0-2.sql
    /sql/com.acme/eg-schema/1-0-1/1-0-3.sql
    /sql/com.acme/eg-schema/1-0-2/1-0-3.sql

In other words, it should be possible to always be possible to upgrade to the latest ADDITION using a single script.

@alexanderdean alexanderdean added this to the Version 0.6.0 milestone Feb 22, 2016
@alexanderdean alexanderdean changed the title Populate /sql/migrations folder Add SQL migrations between schema ADDITIONs Feb 22, 2016
@alexanderdean
Copy link
Contributor Author

Feedback @lesjonesiv, @yalisassoon, @chuwy ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants