schema_plus_enums 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad8cf6ebb0d21c741326bdb6f5715fd4d3907724
4
- data.tar.gz: 56da3f47d07ed577455bb955a64e4b8db2c740bd
3
+ metadata.gz: 80f13da481f41ddac140763aded6ce9abe184d5f
4
+ data.tar.gz: 68971a70fc66f1e4054ac1a12a24f11c05750eb7
5
5
  SHA512:
6
- metadata.gz: 1447dacc6fd9173d1ea79b2ae04d0e89ca45547c63a8373e15a6f892411a0fef141bbf3d53778822d6e196651a173d63f80bee4580d16bc2f36eaeae274e2dba
7
- data.tar.gz: bb1a5487853a8e3f92b7df41310106c27f83c06bcfd914fc5c565c44ff3517832364b62f9b9edbfc2b345bd2e5ba7fcc5fa6ed66be096308e04d66849ac26d70
6
+ metadata.gz: 32c77d1666a305e4da9a3677dcd1e93968525189d935e0671682d02fe4d3a986a40ada495d0659d47f392ebfa85fcba6e7592c6b80f5f85f5afd5329b7214d0d
7
+ data.tar.gz: 73e8ca97ebdf000da2fbdf48d2e91cd97ce1536190ca9bcf3a2688851636dd197c751f9bfec8e07fa4afc66d70d184d731cb58b3a1f7c8759c13447da68810d7
data/.travis.yml CHANGED
@@ -10,7 +10,7 @@ gemfile:
10
10
  - gemfiles/activerecord-4.2/Gemfile.postgresql
11
11
  env: POSTGRESQL_DB_USER=postgres
12
12
  addons:
13
- postgresql: '9.3'
13
+ postgresql: '9.4'
14
14
  before_script: bundle exec rake create_databases
15
15
  after_script: bundle exec rake drop_databases
16
16
  script: bundle exec rake travis
data/README.md CHANGED
@@ -35,16 +35,34 @@ SchemaPlus::Enums is tested on:
35
35
 
36
36
  ## Usage
37
37
 
38
- In a migration:
38
+ In a migration,
39
+ an enum can be created:
39
40
 
40
41
  ```ruby
41
- create_enum :color, 'red', 'green', 'blue'
42
+ create_enum :color, 'red', 'green', 'blue' # default schema is 'public'
42
43
  create_enum :color, 'cyan', 'magenta', 'yellow', 'black', schema: 'cmyk'
43
44
  ```
44
45
 
46
+ And can be altered: (added a new value)
47
+
48
+ ```ruby
49
+ alter_enum :color, 'black'
50
+ alter_enum :color, 'purple', after: 'red'
51
+ alter_enum :color, 'pink', before: 'purple'
52
+ alter_enum :color, 'white', schema: 'public'
53
+ ```
54
+
55
+ And can be dropped:
56
+
57
+ ```ruby
58
+ drop_enum :color
59
+ drop_enum :color, schema: 'cmyk'
60
+ ```
61
+
45
62
 
46
63
  ## History
47
64
 
65
+ * 0.1.1 - Clean up and sort dumper output. Thanks to [@pik](https://github.com/pik)
48
66
  * 0.1.0 - Initial release, pulled from schema_plus 1.x
49
67
 
50
68
  ## Development & Testing
@@ -7,12 +7,12 @@ module SchemaPlus::Enums
7
7
  module Postgresql
8
8
 
9
9
  def after(env)
10
- env.connection.enums.each do |schema, name, values|
10
+ env.connection.enums.sort_by(&its[1]).each do |schema, name, values|
11
11
  params = [name.inspect]
12
12
  params << values.map(&:inspect).join(', ')
13
13
  params << ":schema => #{schema.inspect}" if schema != 'public'
14
14
 
15
- env.initial << "create_enum #{params.join(', ')}"
15
+ env.initial << " create_enum #{params.join(', ')}"
16
16
  end
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  module SchemaPlus
2
2
  module Enums
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -15,6 +15,18 @@ describe "Schema dump" do
15
15
  end
16
16
  end
17
17
 
18
+ it 'should list enums alphabetically' do
19
+ begin
20
+ connection.execute "CREATE TYPE height AS ENUM ('tall', 'medium', 'short')"
21
+ connection.execute "CREATE TYPE color AS ENUM ('red', 'green', 'blue')"
22
+ expect(dump_schema).to match(%r{create_enum "color", "red", "green", "blue"\s+create_enum "height", "tall", "medium", "short"}m)
23
+ ensure
24
+ connection.execute "DROP TYPE color"
25
+ connection.execute "DROP TYPE height"
26
+ end
27
+ end
28
+
29
+
18
30
  it 'should include enum with schema' do
19
31
  begin
20
32
  connection.execute "CREATE SCHEMA cmyk; CREATE TYPE cmyk.color AS ENUM ('cyan', 'magenta', 'yellow', 'black')"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus_enums
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-13 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord