schema_plus_enums 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.travis.yml +1 -1
 - data/README.md +20 -2
 - data/lib/schema_plus/enums/middleware.rb +2 -2
 - data/lib/schema_plus/enums/version.rb +1 -1
 - data/spec/schema_dumper_spec.rb +12 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 80f13da481f41ddac140763aded6ce9abe184d5f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 68971a70fc66f1e4054ac1a12a24f11c05750eb7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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. 
     | 
| 
      
 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
         
     | 
    
        data/spec/schema_dumper_spec.rb
    CHANGED
    
    | 
         @@ -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. 
     | 
| 
      
 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:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-01-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activerecord
         
     |