schema_plus 2.0.0.pre2 → 2.0.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/Gemfile +2 -0
- data/README.md +4 -4
- data/TODO.md +3 -10
- data/gemfiles/{rails-4.2 → activerecord-4.2}/Gemfile.base +1 -1
- data/gemfiles/{rails-4.2 → activerecord-4.2}/Gemfile.mysql2 +0 -0
- data/gemfiles/{rails-4.2 → activerecord-4.2}/Gemfile.postgresql +0 -0
- data/gemfiles/{rails-4.2 → activerecord-4.2}/Gemfile.sqlite3 +0 -0
- data/lib/schema_plus.rb +13 -121
- data/lib/schema_plus/version.rb +1 -1
- data/lib/schema_plus_columns.rb +7 -0
- data/lib/{schema_column_plus → schema_plus_columns}/active_record/connection_adapters/column.rb +1 -1
- data/lib/schema_plus_columns/middleware/model.rb +16 -0
- data/lib/schema_plus_db_default.rb +13 -0
- data/lib/{schema_db_default → schema_plus_db_default}/active_record/attribute.rb +4 -4
- data/lib/{schema_db_default → schema_plus_db_default}/db_default.rb +1 -1
- data/lib/schema_plus_db_default/middleware.rb +30 -0
- data/lib/{schema_default_expr.rb → schema_plus_default_expr.rb} +6 -6
- data/lib/{schema_default_expr → schema_plus_default_expr}/active_record/connection_adapters/mysql2_adapter.rb +1 -1
- data/lib/{schema_default_expr → schema_plus_default_expr}/active_record/connection_adapters/postgresql_adapter.rb +1 -1
- data/lib/{schema_default_expr → schema_plus_default_expr}/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
- data/lib/{schema_default_expr → schema_plus_default_expr}/middleware.rb +21 -19
- data/lib/schema_plus_enums.rb +6 -0
- data/lib/{schema_pg_enums → schema_plus_enums}/active_record.rb +1 -1
- data/lib/schema_plus_enums/middleware.rb +22 -0
- data/lib/schema_plus_foreign_keys.rb +96 -0
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/base.rb +2 -2
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/abstract_adapter.rb +7 -7
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/foreign_key_definition.rb +4 -4
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/mysql2_adapter.rb +9 -9
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/postgresql_adapter.rb +5 -5
- data/lib/schema_plus_foreign_keys/active_record/connection_adapters/schema_statements.rb +33 -0
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/sqlite3_adapter.rb +5 -5
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/table_definition.rb +8 -8
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/migration/command_recorder.rb +5 -5
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/schema.rb +7 -7
- data/lib/{schema_plus → schema_plus_foreign_keys}/middleware/dumper.rb +11 -26
- data/lib/{schema_plus → schema_plus_foreign_keys}/middleware/migration.rb +14 -15
- data/lib/schema_plus_foreign_keys/middleware/model.rb +15 -0
- data/lib/schema_plus_foreign_keys/version.rb +3 -0
- data/lib/schema_plus_views.rb +16 -0
- data/lib/{schema_views → schema_plus_views}/active_record/connection_adapters/abstract_adapter.rb +1 -1
- data/lib/{schema_views → schema_plus_views}/active_record/connection_adapters/mysql2_adapter.rb +1 -1
- data/lib/{schema_views → schema_plus_views}/active_record/connection_adapters/postgresql_adapter.rb +1 -1
- data/lib/{schema_views → schema_plus_views}/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
- data/lib/schema_plus_views/middleware.rb +49 -0
- data/schema_dev.yml +1 -1
- data/schema_plus.gemspec +3 -2
- data/spec/{schema_column_plus → schema_plus_columns}/column_spec.rb +0 -0
- data/spec/{schema_db_default → schema_plus_db_default}/column_spec.rb +1 -1
- data/spec/{schema_default_expr → schema_plus_default_expr}/column_default_spec.rb +0 -0
- data/spec/schema_plus_default_expr/migration_spec.rb +44 -0
- data/spec/{schema_default_expr → schema_plus_default_expr}/schema_dumper_spec.rb +2 -2
- data/spec/{schema_pg_enums → schema_plus_enums}/enum_spec.rb +0 -0
- data/spec/{schema_pg_enums → schema_plus_enums}/schema_dumper_spec.rb +0 -0
- data/spec/{foreign_key_definition_spec.rb → schema_plus_foreign_keys/foreign_key_definition_spec.rb} +0 -0
- data/spec/{foreign_key_spec.rb → schema_plus_foreign_keys/foreign_key_spec.rb} +2 -2
- data/spec/{migration_spec.rb → schema_plus_foreign_keys/migration_spec.rb} +13 -29
- data/spec/{named_schemas_spec.rb → schema_plus_foreign_keys/named_schemas_spec.rb} +0 -0
- data/spec/{schema_dumper_spec.rb → schema_plus_foreign_keys/schema_dumper_spec.rb} +2 -2
- data/spec/{schema_spec.rb → schema_plus_foreign_keys/schema_spec.rb} +7 -7
- data/spec/{schema_views → schema_plus_views}/named_schemas_spec.rb +7 -7
- data/spec/{schema_views → schema_plus_views}/views_spec.rb +0 -0
- data/spec/spec_helper.rb +3 -3
- metadata +102 -81
- data/init.rb +0 -1
- data/lib/schema_column_plus.rb +0 -7
- data/lib/schema_column_plus/middleware/model.rb +0 -22
- data/lib/schema_db_default.rb +0 -13
- data/lib/schema_db_default/middleware.rb +0 -30
- data/lib/schema_pg_enums.rb +0 -6
- data/lib/schema_pg_enums/middleware.rb +0 -23
- data/lib/schema_plus/active_record/connection_adapters/schema_statements.rb +0 -34
- data/lib/schema_plus/middleware/model.rb +0 -17
- data/lib/schema_views.rb +0 -16
- data/lib/schema_views/middleware.rb +0 -47
- data/spec/connection_spec.rb +0 -10
@@ -1,23 +0,0 @@
|
|
1
|
-
module SchemaPgEnums
|
2
|
-
module Middleware
|
3
|
-
module Postgresql
|
4
|
-
def self.insert
|
5
|
-
SchemaMonkey::Middleware::Dumper::Extensions.append CreateEnums
|
6
|
-
end
|
7
|
-
|
8
|
-
class CreateEnums < SchemaMonkey::Middleware::Base
|
9
|
-
def call(env)
|
10
|
-
continue env
|
11
|
-
|
12
|
-
env.connection.enums.each do |schema, name, values|
|
13
|
-
params = [name.inspect]
|
14
|
-
params << values.map(&:inspect).join(', ')
|
15
|
-
params << ":schema => #{schema.inspect}" if schema != 'public'
|
16
|
-
|
17
|
-
env.extensions << "create_enum #{params.join(', ')}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module SchemaPlus::ActiveRecord::ConnectionAdapters
|
2
|
-
module SchemaStatements
|
3
|
-
|
4
|
-
def self.included(base) #:nodoc:
|
5
|
-
base.class_eval do
|
6
|
-
alias_method_chain :create_table, :schema_plus
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
##
|
11
|
-
# :method: create_table
|
12
|
-
#
|
13
|
-
# SchemaPlus extends SchemaStatements::create_table to allow you to specify configuration options per table. Pass them in as a hash keyed by configuration set (see SchemaPlus::Config),
|
14
|
-
# for example:
|
15
|
-
#
|
16
|
-
# create_table :widgets, :foreign_keys => {:auto_create => true, :on_delete => :cascade} do |t|
|
17
|
-
# ...
|
18
|
-
# end
|
19
|
-
def create_table_with_schema_plus(table, options = {})
|
20
|
-
options = options.dup
|
21
|
-
config_options = {}
|
22
|
-
options.keys.each { |key| config_options[key] = options.delete(key) if SchemaPlus.config.class.attributes.include? key }
|
23
|
-
|
24
|
-
# override rails' :force to cascade
|
25
|
-
drop_table(table, if_exists: true, cascade: true) if options.delete(:force)
|
26
|
-
|
27
|
-
create_table_without_schema_plus(table, options) do |table_definition|
|
28
|
-
table_definition.schema_plus_config = SchemaPlus.config.merge(config_options)
|
29
|
-
yield table_definition if block_given?
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module SchemaPlus
|
2
|
-
module Middleware
|
3
|
-
module Model
|
4
|
-
|
5
|
-
def self.insert
|
6
|
-
SchemaMonkey::Middleware::Model::ResetColumnInformation.append ResetColumnInformation
|
7
|
-
end
|
8
|
-
|
9
|
-
class ResetColumnInformation < SchemaMonkey::Middleware::Base
|
10
|
-
def call(env)
|
11
|
-
continue env
|
12
|
-
env.model.reset_foreign_key_information
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/schema_views.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'schema_monkey'
|
2
|
-
|
3
|
-
require_relative 'schema_views/active_record/connection_adapters/abstract_adapter'
|
4
|
-
require_relative 'schema_views/middleware'
|
5
|
-
|
6
|
-
module SchemaViews
|
7
|
-
module ActiveRecord
|
8
|
-
module ConnectionAdapters
|
9
|
-
autoload :Mysql2Adapter, 'schema_views/active_record/connection_adapters/mysql2_adapter'
|
10
|
-
autoload :PostgresqlAdapter, 'schema_views/active_record/connection_adapters/postgresql_adapter'
|
11
|
-
autoload :Sqlite3Adapter, 'schema_views/active_record/connection_adapters/sqlite3_adapter'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
SchemaMonkey.register(SchemaViews)
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module SchemaViews
|
2
|
-
module Middleware
|
3
|
-
def self.insert
|
4
|
-
SchemaMonkey::Middleware::Dumper::Tables.prepend DumpViews
|
5
|
-
end
|
6
|
-
module Mysql
|
7
|
-
def self.insert
|
8
|
-
SchemaMonkey::Middleware::Query::Tables.append FilterOutViews
|
9
|
-
end
|
10
|
-
end
|
11
|
-
module Sqlite3
|
12
|
-
def self.insert
|
13
|
-
SchemaMonkey::Middleware::Query::Tables.append FilterOutViews
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class FilterOutViews < SchemaMonkey::Middleware::Base
|
19
|
-
def call(env)
|
20
|
-
continue env
|
21
|
-
env.tables -= env.connection.views(env.query_name)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class DumpViews < SchemaMonkey::Middleware::Base
|
26
|
-
|
27
|
-
# quacks like a SchemaMonkey Dump::Table
|
28
|
-
class View < KeyStruct[:name, :definition]
|
29
|
-
def assemble(stream)
|
30
|
-
stream.puts(" create_view #{name.inspect}, #{definition.inspect}, :force => true\n")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def call(env)
|
35
|
-
continue env
|
36
|
-
|
37
|
-
re_view_referent = %r{(?:(?i)FROM|JOIN) \S*\b(\S+)\b}
|
38
|
-
env.connection.views.each do |view_name|
|
39
|
-
next if env.dumper.ignored?(view_name)
|
40
|
-
view = View.new(name: view_name, definition: env.connection.view_definition(view_name))
|
41
|
-
env.dump.tables[view.name] = view
|
42
|
-
env.dump.depends(view.name, view.definition.scan(re_view_referent).flatten)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
data/spec/connection_spec.rb
DELETED