From 898bd849aa811d4d2edf0f2460cda07c3404c3db Mon Sep 17 00:00:00 2001 From: Ryan Slade Date: Thu, 31 Oct 2024 17:17:42 +0100 Subject: [PATCH] Add enum column examples (#444) Closes #376 --- docs/README.md | 1 + examples/.ledger | 2 ++ examples/40_create_enum_type.json | 10 ++++++++++ examples/41_add_enum_column.json | 15 +++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 examples/40_create_enum_type.json create mode 100644 examples/41_add_enum_column.json diff --git a/docs/README.md b/docs/README.md index 72d839d3..9c3a0801 100644 --- a/docs/README.md +++ b/docs/README.md @@ -741,6 +741,7 @@ Example **add column** migrations: * [17_add_rating_column.json](../examples/17_add_rating_column.json) * [26_add_column_with_check_constraint.json](../examples/26_add_column_with_check_constraint.json) * [30_add_column_simple_up.json](../examples/30_add_column_simple_up.json) +* [41_add_enum_column.json](../examples/41_add_enum_column.json) ### Alter column diff --git a/examples/.ledger b/examples/.ledger index 9e8bd01d..184ac352 100644 --- a/examples/.ledger +++ b/examples/.ledger @@ -37,3 +37,5 @@ 37_create_partial_index.json 38_create_hash_index_with_fillfactor.json 39_add_column_with_multiple_pk_in_table.json +40_create_enum_type.json +41_add_enum_column.json diff --git a/examples/40_create_enum_type.json b/examples/40_create_enum_type.json new file mode 100644 index 00000000..b971da84 --- /dev/null +++ b/examples/40_create_enum_type.json @@ -0,0 +1,10 @@ +{ + "name": "40_create_enum_type", + "operations": [ + { + "sql": { + "up": "CREATE TYPE fruit_size AS ENUM ('small', 'medium', 'large');" + } + } + ] +} diff --git a/examples/41_add_enum_column.json b/examples/41_add_enum_column.json new file mode 100644 index 00000000..cfb7cc27 --- /dev/null +++ b/examples/41_add_enum_column.json @@ -0,0 +1,15 @@ +{ + "name": "41_add_enum_column", + "operations": [ + { + "add_column": { + "table": "fruits", + "column": { + "name": "size", + "type": "fruit_size", + "default": "'small'" + } + } + } + ] +}