activerecord-import 2.1.0 → 2.3.0
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/CHANGELOG.md +39 -0
- data/README.markdown +9 -9
- data/lib/activerecord-import/active_record/adapters/mysql2_proxy_adapter.rb +8 -0
- data/lib/activerecord-import/active_record/adapters/postgresql_proxy_adapter.rb +8 -0
- data/lib/activerecord-import/active_record/adapters/sqlite3_proxy_adapter.rb +8 -0
- data/lib/activerecord-import/active_record/adapters/trilogy_proxy_adapter.rb +8 -0
- data/lib/activerecord-import/adapters/active_record_proxy_adapter.rb +19 -0
- data/lib/activerecord-import/adapters/mysql2_proxy_adapter.rb +9 -0
- data/lib/activerecord-import/adapters/mysql_adapter.rb +10 -3
- data/lib/activerecord-import/adapters/postgresql_adapter.rb +1 -1
- data/lib/activerecord-import/adapters/postgresql_proxy_adapter.rb +9 -0
- data/lib/activerecord-import/adapters/sqlite3_adapter.rb +1 -1
- data/lib/activerecord-import/adapters/sqlite3_proxy_adapter.rb +9 -0
- data/lib/activerecord-import/adapters/trilogy_proxy_adapter.rb +9 -0
- data/lib/activerecord-import/base.rb +2 -2
- data/lib/activerecord-import/import.rb +243 -211
- data/lib/activerecord-import/version.rb +1 -1
- metadata +13 -200
- data/.github/workflows/test.yaml +0 -161
- data/.gitignore +0 -37
- data/.rubocop.yml +0 -118
- data/.rubocop_todo.yml +0 -30
- data/Brewfile +0 -5
- data/Dockerfile +0 -23
- data/Gemfile +0 -63
- data/Rakefile +0 -73
- data/activerecord-import.gemspec +0 -28
- data/benchmarks/README +0 -32
- data/benchmarks/benchmark.rb +0 -72
- data/benchmarks/lib/base.rb +0 -143
- data/benchmarks/lib/cli_parser.rb +0 -111
- data/benchmarks/lib/float.rb +0 -17
- data/benchmarks/lib/mysql2_benchmark.rb +0 -21
- data/benchmarks/lib/output_to_csv.rb +0 -21
- data/benchmarks/lib/output_to_html.rb +0 -66
- data/benchmarks/models/test_innodb.rb +0 -5
- data/benchmarks/models/test_memory.rb +0 -5
- data/benchmarks/models/test_myisam.rb +0 -5
- data/benchmarks/schema/mysql2_schema.rb +0 -18
- data/docker-compose.yml +0 -34
- data/gemfiles/5.2.gemfile +0 -4
- data/gemfiles/6.0.gemfile +0 -4
- data/gemfiles/6.1.gemfile +0 -4
- data/gemfiles/7.0.gemfile +0 -4
- data/gemfiles/7.1.gemfile +0 -3
- data/gemfiles/7.2.gemfile +0 -3
- data/gemfiles/8.0.gemfile +0 -3
- data/test/adapters/jdbcmysql.rb +0 -3
- data/test/adapters/jdbcpostgresql.rb +0 -3
- data/test/adapters/jdbcsqlite3.rb +0 -3
- data/test/adapters/makara_postgis.rb +0 -3
- data/test/adapters/mysql2.rb +0 -3
- data/test/adapters/mysql2_makara.rb +0 -3
- data/test/adapters/mysql2_proxy.rb +0 -3
- data/test/adapters/mysql2spatial.rb +0 -3
- data/test/adapters/postgis.rb +0 -3
- data/test/adapters/postgresql.rb +0 -3
- data/test/adapters/postgresql_makara.rb +0 -3
- data/test/adapters/postgresql_proxy.rb +0 -3
- data/test/adapters/seamless_database_pool.rb +0 -3
- data/test/adapters/spatialite.rb +0 -3
- data/test/adapters/sqlite3.rb +0 -3
- data/test/adapters/trilogy.rb +0 -11
- data/test/database.yml.sample +0 -65
- data/test/github/database.yml +0 -78
- data/test/import_test.rb +0 -970
- data/test/jdbcmysql/import_test.rb +0 -7
- data/test/jdbcpostgresql/import_test.rb +0 -6
- data/test/jdbcsqlite3/import_test.rb +0 -6
- data/test/makara_postgis/import_test.rb +0 -10
- data/test/models/account.rb +0 -5
- data/test/models/alarm.rb +0 -4
- data/test/models/animal.rb +0 -8
- data/test/models/author.rb +0 -9
- data/test/models/bike_maker.rb +0 -10
- data/test/models/book.rb +0 -18
- data/test/models/car.rb +0 -5
- data/test/models/card.rb +0 -5
- data/test/models/chapter.rb +0 -6
- data/test/models/composite_book.rb +0 -19
- data/test/models/composite_chapter.rb +0 -12
- data/test/models/customer.rb +0 -18
- data/test/models/deck.rb +0 -8
- data/test/models/dictionary.rb +0 -6
- data/test/models/discount.rb +0 -5
- data/test/models/end_note.rb +0 -6
- data/test/models/group.rb +0 -5
- data/test/models/order.rb +0 -17
- data/test/models/playing_card.rb +0 -4
- data/test/models/promotion.rb +0 -5
- data/test/models/question.rb +0 -5
- data/test/models/rule.rb +0 -5
- data/test/models/tag.rb +0 -12
- data/test/models/tag_alias.rb +0 -11
- data/test/models/topic.rb +0 -31
- data/test/models/user.rb +0 -5
- data/test/models/user_token.rb +0 -6
- data/test/models/vendor.rb +0 -9
- data/test/models/widget.rb +0 -33
- data/test/mysql2/import_test.rb +0 -7
- data/test/mysql2_makara/import_test.rb +0 -8
- data/test/mysql2_proxy/import_test.rb +0 -6
- data/test/mysqlspatial2/import_test.rb +0 -8
- data/test/postgis/import_test.rb +0 -10
- data/test/postgresql/import_test.rb +0 -6
- data/test/postgresql_proxy/import_test.rb +0 -6
- data/test/schema/generic_schema.rb +0 -230
- data/test/schema/jdbcpostgresql_schema.rb +0 -3
- data/test/schema/mysql2_schema.rb +0 -21
- data/test/schema/postgis_schema.rb +0 -3
- data/test/schema/postgresql_schema.rb +0 -94
- data/test/schema/sqlite3_schema.rb +0 -15
- data/test/schema/version.rb +0 -12
- data/test/sqlite3/import_test.rb +0 -6
- data/test/support/active_support/test_case_extensions.rb +0 -73
- data/test/support/assertions.rb +0 -75
- data/test/support/factories.rb +0 -66
- data/test/support/generate.rb +0 -31
- data/test/support/mysql/import_examples.rb +0 -97
- data/test/support/postgresql/import_examples.rb +0 -642
- data/test/support/shared_examples/on_duplicate_key_ignore.rb +0 -45
- data/test/support/shared_examples/on_duplicate_key_update.rb +0 -437
- data/test/support/shared_examples/recursive_import.rb +0 -352
- data/test/support/sqlite3/import_examples.rb +0 -232
- data/test/synchronize_test.rb +0 -43
- data/test/test_helper.rb +0 -91
- data/test/trilogy/import_test.rb +0 -7
- data/test/value_sets_bytes_parser_test.rb +0 -106
- data/test/value_sets_records_parser_test.rb +0 -34
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
6
|
-
|
|
7
|
-
should_support_mysql_import_functionality
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/postgresql/import_examples")
|
|
5
|
-
|
|
6
|
-
should_support_postgresql_import_functionality
|
|
7
|
-
|
|
8
|
-
if ActiveRecord::Base.connection.supports_on_duplicate_key_update?
|
|
9
|
-
should_support_postgresql_upsert_functionality
|
|
10
|
-
end
|
data/test/models/account.rb
DELETED
data/test/models/alarm.rb
DELETED
data/test/models/animal.rb
DELETED
data/test/models/author.rb
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Author < ActiveRecord::Base
|
|
4
|
-
if ENV['AR_VERSION'].to_f >= 8.0
|
|
5
|
-
has_many :composite_books, foreign_key: [:id, :author_id], inverse_of: :author
|
|
6
|
-
elsif ENV['AR_VERSION'].to_f >= 7.1
|
|
7
|
-
has_many :composite_books, query_constraints: [:id, :author_id], inverse_of: :author
|
|
8
|
-
end
|
|
9
|
-
end
|
data/test/models/bike_maker.rb
DELETED
data/test/models/book.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Book < ActiveRecord::Base
|
|
4
|
-
belongs_to :topic, inverse_of: :books
|
|
5
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
6
|
-
belongs_to :tag, foreign_key: [:tag_id, :parent_id] unless ENV["SKIP_COMPOSITE_PK"]
|
|
7
|
-
else
|
|
8
|
-
belongs_to :tag, query_constraints: [:tag_id, :parent_id] unless ENV["SKIP_COMPOSITE_PK"]
|
|
9
|
-
end
|
|
10
|
-
has_many :chapters, inverse_of: :book
|
|
11
|
-
has_many :discounts, as: :discountable
|
|
12
|
-
has_many :end_notes, inverse_of: :book
|
|
13
|
-
if ENV['AR_VERSION'].to_f >= 8.0
|
|
14
|
-
enum :status, [:draft, :published]
|
|
15
|
-
else
|
|
16
|
-
enum status: [:draft, :published]
|
|
17
|
-
end
|
|
18
|
-
end
|
data/test/models/car.rb
DELETED
data/test/models/card.rb
DELETED
data/test/models/chapter.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CompositeBook < ActiveRecord::Base
|
|
4
|
-
self.primary_key = %i[id author_id]
|
|
5
|
-
belongs_to :author
|
|
6
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
7
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
8
|
-
has_many :composite_chapters, inverse_of: :composite_book,
|
|
9
|
-
foreign_key: [:id, :author_id]
|
|
10
|
-
end
|
|
11
|
-
else
|
|
12
|
-
has_many :composite_chapters, inverse_of: :composite_book,
|
|
13
|
-
query_constraints: [:id, :author_id]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def self.sequence_name
|
|
17
|
-
"composite_book_id_seq"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CompositeChapter < ActiveRecord::Base
|
|
4
|
-
if ENV['AR_VERSION'].to_f >= 8.0
|
|
5
|
-
belongs_to :composite_book, inverse_of: :composite_chapters,
|
|
6
|
-
foreign_key: [:composite_book_id, :author_id]
|
|
7
|
-
elsif ENV['AR_VERSION'].to_f >= 7.1
|
|
8
|
-
belongs_to :composite_book, inverse_of: :composite_chapters,
|
|
9
|
-
query_constraints: [:composite_book_id, :author_id]
|
|
10
|
-
end
|
|
11
|
-
validates :title, presence: true
|
|
12
|
-
end
|
data/test/models/customer.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Customer < ActiveRecord::Base
|
|
4
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
5
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
6
|
-
has_many :orders,
|
|
7
|
-
inverse_of: :customer,
|
|
8
|
-
primary_key: %i(account_id id),
|
|
9
|
-
foreign_key: %i(account_id customer_id)
|
|
10
|
-
else
|
|
11
|
-
has_many :orders,
|
|
12
|
-
inverse_of: :customer,
|
|
13
|
-
primary_key: %i(account_id id),
|
|
14
|
-
query_constraints: %i(account_id customer_id)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
end
|
data/test/models/deck.rb
DELETED
data/test/models/dictionary.rb
DELETED
data/test/models/discount.rb
DELETED
data/test/models/end_note.rb
DELETED
data/test/models/group.rb
DELETED
data/test/models/order.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Order < ActiveRecord::Base
|
|
4
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
5
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
6
|
-
belongs_to :customer,
|
|
7
|
-
inverse_of: :orders,
|
|
8
|
-
primary_key: %i(account_id id),
|
|
9
|
-
foreign_key: %i(account_id customer_id)
|
|
10
|
-
else
|
|
11
|
-
belongs_to :customer,
|
|
12
|
-
inverse_of: :orders,
|
|
13
|
-
primary_key: %i(account_id id),
|
|
14
|
-
query_constraints: %i(account_id customer_id)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
data/test/models/playing_card.rb
DELETED
data/test/models/promotion.rb
DELETED
data/test/models/question.rb
DELETED
data/test/models/rule.rb
DELETED
data/test/models/tag.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Tag < ActiveRecord::Base
|
|
4
|
-
if ENV['AR_VERSION'].to_f <= 7.0
|
|
5
|
-
self.primary_keys = :tag_id, :publisher_id unless ENV["SKIP_COMPOSITE_PK"]
|
|
6
|
-
else
|
|
7
|
-
self.primary_key = [:tag_id, :publisher_id] unless ENV["SKIP_COMPOSITE_PK"]
|
|
8
|
-
end
|
|
9
|
-
self.primary_key = [:tag_id, :publisher_id] unless ENV["SKIP_COMPOSITE_PK"]
|
|
10
|
-
has_many :books, inverse_of: :tag
|
|
11
|
-
has_many :tag_aliases, inverse_of: :tag
|
|
12
|
-
end
|
data/test/models/tag_alias.rb
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class TagAlias < ActiveRecord::Base
|
|
4
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
5
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
6
|
-
belongs_to :tag, foreign_key: [:tag_id, :parent_id], required: true
|
|
7
|
-
else
|
|
8
|
-
belongs_to :tag, query_constraints: [:tag_id, :parent_id], required: true
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
data/test/models/topic.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Topic < ActiveRecord::Base
|
|
4
|
-
if ENV['AR_VERSION'].to_f >= 6.0
|
|
5
|
-
self.ignored_columns = [:priority]
|
|
6
|
-
end
|
|
7
|
-
alias_attribute :name, :title
|
|
8
|
-
|
|
9
|
-
validates_presence_of :author_name
|
|
10
|
-
validates :title, numericality: { only_integer: true }, on: :context_test
|
|
11
|
-
validates :title, uniqueness: true
|
|
12
|
-
validates :content, uniqueness: true
|
|
13
|
-
validates :word_count, numericality: { greater_than: 0 }, if: :content?
|
|
14
|
-
|
|
15
|
-
validate -> { errors.add(:title, :validate_failed) if title == 'validate_failed' }
|
|
16
|
-
before_validation -> { errors.add(:title, :invalid) if title == 'invalid' }
|
|
17
|
-
|
|
18
|
-
has_many :books, inverse_of: :topic
|
|
19
|
-
has_many :novels, inverse_of: :topic, class_name: "Book"
|
|
20
|
-
belongs_to :parent, class_name: "Topic"
|
|
21
|
-
|
|
22
|
-
composed_of :description, mapping: [%w(title title), %w(author_name author_name)], allow_nil: true, class_name: "TopicDescription"
|
|
23
|
-
|
|
24
|
-
default_scope { where(approved: true) }
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def word_count
|
|
29
|
-
@word_count ||= content.to_s.scan(/\w+/).count
|
|
30
|
-
end
|
|
31
|
-
end
|
data/test/models/user.rb
DELETED
data/test/models/user_token.rb
DELETED
data/test/models/vendor.rb
DELETED
data/test/models/widget.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CustomCoder
|
|
4
|
-
def load(value)
|
|
5
|
-
if value.nil?
|
|
6
|
-
{}
|
|
7
|
-
else
|
|
8
|
-
YAML.load(value)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def dump(value)
|
|
13
|
-
YAML.dump(value)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class Widget < ActiveRecord::Base
|
|
18
|
-
self.primary_key = :w_id
|
|
19
|
-
|
|
20
|
-
default_scope -> { where(active: true) }
|
|
21
|
-
|
|
22
|
-
if ENV['AR_VERSION'].to_f >= 7.1
|
|
23
|
-
serialize :data, coder: YAML
|
|
24
|
-
serialize :json_data, coder: JSON
|
|
25
|
-
serialize :custom_data, coder: CustomCoder.new
|
|
26
|
-
else
|
|
27
|
-
serialize :data, Hash
|
|
28
|
-
serialize :json_data, JSON
|
|
29
|
-
serialize :custom_data, CustomCoder.new
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
serialize :unspecified_data
|
|
33
|
-
end
|
data/test/mysql2/import_test.rb
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
6
|
-
|
|
7
|
-
should_support_mysql_import_functionality
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
6
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
7
|
-
|
|
8
|
-
should_support_mysql_import_functionality
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
6
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
7
|
-
|
|
8
|
-
should_support_mysql_import_functionality
|
data/test/postgis/import_test.rb
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/postgresql/import_examples")
|
|
5
|
-
|
|
6
|
-
should_support_postgresql_import_functionality
|
|
7
|
-
|
|
8
|
-
if ActiveRecord::Base.connection.supports_on_duplicate_key_update?
|
|
9
|
-
should_support_postgresql_upsert_functionality
|
|
10
|
-
end
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
ActiveRecord::Schema.define do
|
|
4
|
-
create_table :schema_info, force: :cascade do |t|
|
|
5
|
-
t.integer :version
|
|
6
|
-
end
|
|
7
|
-
add_index :schema_info, :version, unique: true
|
|
8
|
-
|
|
9
|
-
SchemaInfo.create version: SchemaInfo::VERSION
|
|
10
|
-
|
|
11
|
-
create_table :group, force: :cascade do |t|
|
|
12
|
-
t.string :order
|
|
13
|
-
t.timestamps null: true
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
create_table :topics, force: :cascade do |t|
|
|
17
|
-
t.string :title, null: false
|
|
18
|
-
t.string :author_name
|
|
19
|
-
t.string :author_email_address
|
|
20
|
-
t.datetime :written_on
|
|
21
|
-
t.time :bonus_time
|
|
22
|
-
t.datetime :last_read
|
|
23
|
-
t.text :content
|
|
24
|
-
t.boolean :approved, default: '1'
|
|
25
|
-
t.integer :replies_count
|
|
26
|
-
t.integer :parent_id
|
|
27
|
-
t.integer :priority, default: 0
|
|
28
|
-
t.string :type
|
|
29
|
-
t.datetime :created_at
|
|
30
|
-
t.datetime :created_on
|
|
31
|
-
t.datetime :updated_at
|
|
32
|
-
t.datetime :updated_on
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
create_table :projects, force: :cascade do |t|
|
|
36
|
-
t.string :name
|
|
37
|
-
t.string :type
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
create_table :developers, force: :cascade do |t|
|
|
41
|
-
t.string :name
|
|
42
|
-
t.integer :salary, default: '70000'
|
|
43
|
-
t.datetime :created_at
|
|
44
|
-
t.integer :team_id
|
|
45
|
-
t.datetime :updated_at
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
create_table :addresses, force: :cascade do |t|
|
|
49
|
-
t.string :address
|
|
50
|
-
t.string :city
|
|
51
|
-
t.string :state
|
|
52
|
-
t.string :zip
|
|
53
|
-
t.integer :developer_id
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
create_table :teams, force: :cascade do |t|
|
|
57
|
-
t.string :name
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
create_table :cards, force: :cascade do |t|
|
|
61
|
-
t.string :name
|
|
62
|
-
t.string :deck_type
|
|
63
|
-
t.integer :deck_id
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
create_table :decks, force: :cascade do |t|
|
|
67
|
-
t.string :name
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
create_table :playing_cards, force: :cascade do |t|
|
|
71
|
-
t.string :name
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
create_table :books, force: :cascade do |t|
|
|
75
|
-
t.string :title, null: false
|
|
76
|
-
t.string :publisher, null: false, default: 'Default Publisher'
|
|
77
|
-
t.string :author_name, null: false
|
|
78
|
-
t.datetime :created_at
|
|
79
|
-
t.datetime :created_on
|
|
80
|
-
t.datetime :updated_at
|
|
81
|
-
t.datetime :updated_on
|
|
82
|
-
t.date :publish_date
|
|
83
|
-
t.integer :topic_id
|
|
84
|
-
t.integer :tag_id
|
|
85
|
-
t.integer :publisher_id
|
|
86
|
-
t.boolean :for_sale, default: true
|
|
87
|
-
t.integer :status, default: 0
|
|
88
|
-
t.string :type
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
create_table :chapters, force: :cascade do |t|
|
|
92
|
-
t.string :title
|
|
93
|
-
t.integer :book_id, null: false
|
|
94
|
-
t.datetime :created_at
|
|
95
|
-
t.datetime :updated_at
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
create_table :end_notes, primary_key: :end_note_id, force: :cascade do |t|
|
|
99
|
-
t.string :note
|
|
100
|
-
t.integer :book_id, null: false
|
|
101
|
-
t.datetime :created_at
|
|
102
|
-
t.datetime :updated_at
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
create_table :languages, force: :cascade do |t|
|
|
106
|
-
t.string :name
|
|
107
|
-
t.integer :developer_id
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
create_table :shopping_carts, force: :cascade do |t|
|
|
111
|
-
t.string :name, null: true
|
|
112
|
-
t.datetime :created_at
|
|
113
|
-
t.datetime :updated_at
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
create_table :cart_items, force: :cascade do |t|
|
|
117
|
-
t.string :shopping_cart_id, null: false
|
|
118
|
-
t.string :book_id, null: false
|
|
119
|
-
t.integer :copies, default: 1
|
|
120
|
-
t.datetime :created_at
|
|
121
|
-
t.datetime :updated_at
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
add_index :cart_items, [:shopping_cart_id, :book_id], unique: true, name: 'uk_shopping_cart_books'
|
|
125
|
-
|
|
126
|
-
create_table :animals, force: :cascade do |t|
|
|
127
|
-
t.string :name, null: false
|
|
128
|
-
t.string :size, default: nil
|
|
129
|
-
t.datetime :created_at
|
|
130
|
-
t.datetime :updated_at
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
add_index :animals, [:name], unique: true, name: 'uk_animals'
|
|
134
|
-
|
|
135
|
-
create_table :widgets, id: false, force: :cascade do |t|
|
|
136
|
-
t.integer :w_id, primary_key: true
|
|
137
|
-
t.boolean :active, default: false
|
|
138
|
-
t.text :data
|
|
139
|
-
t.text :json_data
|
|
140
|
-
t.text :unspecified_data
|
|
141
|
-
t.text :custom_data
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
create_table :promotions, primary_key: :promotion_id, force: :cascade do |t|
|
|
145
|
-
t.string :code
|
|
146
|
-
t.string :description
|
|
147
|
-
t.decimal :discount
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
add_index :promotions, [:code], unique: true, name: 'uk_code'
|
|
151
|
-
|
|
152
|
-
create_table :discounts, force: :cascade do |t|
|
|
153
|
-
t.decimal :amount
|
|
154
|
-
t.integer :discountable_id
|
|
155
|
-
t.string :discountable_type
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
create_table :rules, id: false, force: :cascade do |t|
|
|
159
|
-
t.integer :id
|
|
160
|
-
t.string :condition_text
|
|
161
|
-
t.integer :question_id
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
create_table :questions, force: :cascade do |t|
|
|
165
|
-
t.string :body
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
create_table :vendors, force: :cascade do |t|
|
|
169
|
-
t.string :name, null: true
|
|
170
|
-
t.text :preferences
|
|
171
|
-
t.text :data
|
|
172
|
-
t.text :config
|
|
173
|
-
t.text :settings
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
create_table :cars, id: false, force: :cascade do |t|
|
|
177
|
-
t.string :Name, null: true
|
|
178
|
-
t.string :Features
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
create_table :users, force: :cascade do |t|
|
|
182
|
-
t.string :name, null: false
|
|
183
|
-
t.integer :lock_version, null: false, default: 0
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
create_table :user_tokens, force: :cascade do |t|
|
|
187
|
-
t.string :user_name, null: false
|
|
188
|
-
t.string :token, null: false
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
create_table :accounts, force: :cascade do |t|
|
|
192
|
-
t.string :name, null: false
|
|
193
|
-
t.integer :lock, null: false, default: 0
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
create_table :bike_makers, force: :cascade do |t|
|
|
197
|
-
t.string :name, null: false
|
|
198
|
-
t.integer :lock_version, null: false, default: 0
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
add_index :cars, :Name, unique: true
|
|
202
|
-
|
|
203
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
204
|
-
execute %(
|
|
205
|
-
CREATE TABLE IF NOT EXISTS tags (
|
|
206
|
-
tag_id INT NOT NULL,
|
|
207
|
-
publisher_id INT NOT NULL,
|
|
208
|
-
tag VARCHAR(50),
|
|
209
|
-
PRIMARY KEY (tag_id, publisher_id)
|
|
210
|
-
);
|
|
211
|
-
).split.join(' ').strip
|
|
212
|
-
|
|
213
|
-
create_table :tag_aliases, force: :cascade do |t|
|
|
214
|
-
t.integer :tag_id, null: false
|
|
215
|
-
t.integer :parent_id, null: false
|
|
216
|
-
t.string :alias, null: false
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
create_table :customers, force: :cascade do |t|
|
|
221
|
-
t.integer :account_id
|
|
222
|
-
t.string :name
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
create_table :orders, force: :cascade do |t|
|
|
226
|
-
t.integer :account_id
|
|
227
|
-
t.integer :customer_id
|
|
228
|
-
t.integer :amount
|
|
229
|
-
end
|
|
230
|
-
end
|