Current section
10 Versions
Jump to
Current section
10 Versions
Compare versions
4
files changed
+7
additions
-13
deletions
| @@ -25,7 +25,7 @@ The package can be installed by adding `ecto_enum_migration` to your list of dep | |
| 25 25 | ```elixir |
| 26 26 | def deps do |
| 27 27 | [ |
| 28 | - {:ecto_enum_migration, "~> 0.3.0"} |
| 28 | + {:ecto_enum_migration, "~> 0.3.1"} |
| 29 29 | ] |
| 30 30 | end |
| 31 31 | ``` |
| @@ -21,4 +21,4 @@ | |
| 21 21 | {<<"optional">>,false}, |
| 22 22 | {<<"repository">>,<<"hexpm">>}, |
| 23 23 | {<<"requirement">>,<<">= 0.0.0">>}]]}. |
| 24 | - {<<"version">>,<<"0.3.0">>}. |
| 24 | + {<<"version">>,<<"0.3.1">>}. |
| @@ -184,6 +184,8 @@ defmodule EctoEnumMigration do | |
| 184 184 | @doc """ |
| 185 185 | Rename a value of a Postgres Type. |
| 186 186 | |
| 187 | + ***Only compatible with Postgres version 10+*** |
| 188 | + |
| 187 189 | ## Examples |
| 188 190 | |
| 189 191 | ```elixir |
| @@ -219,19 +221,11 @@ defmodule EctoEnumMigration do | |
| 219 221 | after_value = to_value(after_value) |
| 220 222 | |
| 221 223 | up_sql = " |
| 222 | - UPDATE pg_catalog.pg_enum |
| 223 | - SET enumlabel = #{after_value} |
| 224 | - WHERE enumtypid = '#{type_name}'::regtype::oid |
| 225 | - AND enumlabel = #{before_value} |
| 226 | - RETURNING enumlabel; |
| 224 | + ALTER TYPE #{type_name} RENAME VALUE #{before_value} TO #{after_value}; |
| 227 225 | " |
| 228 226 | |
| 229 227 | down_sql = " |
| 230 | - UPDATE pg_catalog.pg_enum |
| 231 | - SET enumlabel = #{before_value} |
| 232 | - WHERE enumtypid = '#{type_name}'::regtype::oid |
| 233 | - AND enumlabel = #{after_value} |
| 234 | - RETURNING enumlabel; |
| 228 | + ALTER TYPE #{type_name} RENAME VALUE #{after_value} TO #{before_value}; |
| 235 229 | " |
| 236 230 | |
| 237 231 | execute(up_sql, down_sql) |
| @@ -4,7 +4,7 @@ defmodule EctoEnumMigration.MixProject do | |
| 4 4 | def project do |
| 5 5 | [ |
| 6 6 | app: :ecto_enum_migration, |
| 7 | - version: "0.3.0", |
| 7 | + version: "0.3.1", |
| 8 8 | elixir: "~> 1.7", |
| 9 9 | start_permanent: Mix.env() == :prod, |
| 10 10 | deps: deps(), |