rails_redshift_replicator 0.0.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.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/rails_redshift_replicator/application.js +13 -0
  6. data/app/assets/stylesheets/rails_redshift_replicator/application.css +15 -0
  7. data/app/controllers/rails_redshift_replicator/application_controller.rb +5 -0
  8. data/app/helpers/rails_redshift_replicator/application_helper.rb +4 -0
  9. data/app/models/rails_redshift_replicator/replication.rb +98 -0
  10. data/app/views/layouts/rails_redshift_replicator/application.html.erb +14 -0
  11. data/config/locales/rails_redshift_replicator.en.yml +20 -0
  12. data/config/routes.rb +2 -0
  13. data/db/migrate/20160503214955_create_rails_redshift_replicator_replications.rb +24 -0
  14. data/db/migrate/20160509193335_create_table_rails_redshift_replicator_deleted_ids.rb +8 -0
  15. data/lib/generators/rails_redshift_replicator/install_generator.rb +25 -0
  16. data/lib/generators/templates/rails_redshift_replicator.rb +74 -0
  17. data/lib/rails_redshift_replicator.rb +229 -0
  18. data/lib/rails_redshift_replicator/adapters/generic.rb +40 -0
  19. data/lib/rails_redshift_replicator/adapters/mysql2.rb +22 -0
  20. data/lib/rails_redshift_replicator/adapters/postgresql.rb +37 -0
  21. data/lib/rails_redshift_replicator/adapters/sqlite.rb +27 -0
  22. data/lib/rails_redshift_replicator/deleter.rb +67 -0
  23. data/lib/rails_redshift_replicator/engine.rb +14 -0
  24. data/lib/rails_redshift_replicator/exporters/base.rb +215 -0
  25. data/lib/rails_redshift_replicator/exporters/full_replicator.rb +9 -0
  26. data/lib/rails_redshift_replicator/exporters/identity_replicator.rb +9 -0
  27. data/lib/rails_redshift_replicator/exporters/timed_replicator.rb +9 -0
  28. data/lib/rails_redshift_replicator/file_manager.rb +134 -0
  29. data/lib/rails_redshift_replicator/importers/base.rb +158 -0
  30. data/lib/rails_redshift_replicator/importers/full_replicator.rb +17 -0
  31. data/lib/rails_redshift_replicator/importers/identity_replicator.rb +15 -0
  32. data/lib/rails_redshift_replicator/importers/timed_replicator.rb +18 -0
  33. data/lib/rails_redshift_replicator/model/extension.rb +45 -0
  34. data/lib/rails_redshift_replicator/model/hair_trigger_extension.rb +8 -0
  35. data/lib/rails_redshift_replicator/replicable.rb +143 -0
  36. data/lib/rails_redshift_replicator/rlogger.rb +12 -0
  37. data/lib/rails_redshift_replicator/tools/analyze.rb +18 -0
  38. data/lib/rails_redshift_replicator/tools/vacuum.rb +77 -0
  39. data/lib/rails_redshift_replicator/version.rb +3 -0
  40. data/lib/tasks/rails_redshift_replicator_tasks.rake +4 -0
  41. data/spec/dummy/README.rdoc +28 -0
  42. data/spec/dummy/Rakefile +6 -0
  43. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  44. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  45. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  46. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  47. data/spec/dummy/app/models/post.rb +4 -0
  48. data/spec/dummy/app/models/tag.rb +4 -0
  49. data/spec/dummy/app/models/user.rb +5 -0
  50. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  51. data/spec/dummy/bin/bundle +3 -0
  52. data/spec/dummy/bin/rails +4 -0
  53. data/spec/dummy/bin/rake +4 -0
  54. data/spec/dummy/bin/setup +29 -0
  55. data/spec/dummy/config.ru +4 -0
  56. data/spec/dummy/config/application.rb +26 -0
  57. data/spec/dummy/config/boot.rb +5 -0
  58. data/spec/dummy/config/database.yml +37 -0
  59. data/spec/dummy/config/environment.rb +5 -0
  60. data/spec/dummy/config/environments/development.rb +41 -0
  61. data/spec/dummy/config/environments/production.rb +79 -0
  62. data/spec/dummy/config/environments/test.rb +42 -0
  63. data/spec/dummy/config/initializers/assets.rb +11 -0
  64. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  65. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  66. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  67. data/spec/dummy/config/initializers/inflections.rb +16 -0
  68. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  69. data/spec/dummy/config/initializers/rails_redshift_replicator.rb +59 -0
  70. data/spec/dummy/config/initializers/session_store.rb +3 -0
  71. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  72. data/spec/dummy/config/locales/en.yml +23 -0
  73. data/spec/dummy/config/locales/rails_redshift_replicator.en.yml +19 -0
  74. data/spec/dummy/config/routes.rb +4 -0
  75. data/spec/dummy/config/secrets.yml +22 -0
  76. data/spec/dummy/db/development.sqlite3 +0 -0
  77. data/spec/dummy/db/migrate/20160504120421_create_test_tables.rb +40 -0
  78. data/spec/dummy/db/migrate/20160509225445_create_triggers_posts_delete_or_tags_delete_or_users_delete.rb +33 -0
  79. data/spec/dummy/db/migrate/20160511000937_create_rails_redshift_replicator_replications.rails_redshift_replicator.rb +25 -0
  80. data/spec/dummy/db/migrate/20160511000938_create_table_rails_redshift_replicator_deleted_ids.rails_redshift_replicator.rb +9 -0
  81. data/spec/dummy/db/schema.rb +99 -0
  82. data/spec/dummy/db/test.sqlite3 +0 -0
  83. data/spec/dummy/log/development.log +1623 -0
  84. data/spec/dummy/log/test.log +95379 -0
  85. data/spec/dummy/public/404.html +67 -0
  86. data/spec/dummy/public/422.html +67 -0
  87. data/spec/dummy/public/500.html +66 -0
  88. data/spec/dummy/public/favicon.ico +0 -0
  89. data/spec/dummy/rails_redshift_replicator_development +0 -0
  90. data/spec/factories/rails_redshift_replicator_replications.rb +31 -0
  91. data/spec/integration/rails_redshift_replicator_spec.rb +148 -0
  92. data/spec/integration/setup_spec.rb +149 -0
  93. data/spec/lib/rails_redshift_replicator/deleter_spec.rb +90 -0
  94. data/spec/lib/rails_redshift_replicator/exporters/base_spec.rb +326 -0
  95. data/spec/lib/rails_redshift_replicator/exporters/full_replicator_spec.rb +33 -0
  96. data/spec/lib/rails_redshift_replicator/exporters/identity_replicator_spec.rb +40 -0
  97. data/spec/lib/rails_redshift_replicator/exporters/timed_replicator_spec.rb +43 -0
  98. data/spec/lib/rails_redshift_replicator/file_manager_spec.rb +90 -0
  99. data/spec/lib/rails_redshift_replicator/importers/base_spec.rb +102 -0
  100. data/spec/lib/rails_redshift_replicator/importers/full_replicator_spec.rb +27 -0
  101. data/spec/lib/rails_redshift_replicator/importers/identity_replicator_spec.rb +26 -0
  102. data/spec/lib/rails_redshift_replicator/importers/timed_replicator_spec.rb +26 -0
  103. data/spec/lib/rails_redshift_replicator/model/extension_spec.rb +36 -0
  104. data/spec/lib/rails_redshift_replicator/replicable_spec.rb +230 -0
  105. data/spec/lib/rails_redshift_replicator/rlogger_spec.rb +22 -0
  106. data/spec/lib/rails_redshift_replicator/tools/analyze_spec.rb +15 -0
  107. data/spec/lib/rails_redshift_replicator/tools/vacuum_spec.rb +65 -0
  108. data/spec/lib/rails_redshift_replicator_spec.rb +110 -0
  109. data/spec/models/rails_redshift_replicator/replication_spec.rb +104 -0
  110. data/spec/spec_helper.rb +36 -0
  111. data/spec/support/csv/invalid_user.csv +12 -0
  112. data/spec/support/csv/valid_post.csv +2 -0
  113. data/spec/support/csv/valid_tags_users.csv +1 -0
  114. data/spec/support/csv/valid_user.csv +2 -0
  115. data/spec/support/rails_redshift_replicator_helpers.rb +95 -0
  116. metadata +430 -0
@@ -0,0 +1,42 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = true
14
+
15
+ # Configure static file server for tests with Cache-Control for performance.
16
+ config.serve_static_files = true
17
+ config.static_cache_control = 'public, max-age=3600'
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Randomize the order test cases are executed.
35
+ config.active_support.test_order = :random
36
+
37
+ # Print deprecation notices to the stderr.
38
+ config.active_support.deprecation = :stderr
39
+
40
+ # Raises error for missing translations
41
+ # config.action_view.raise_on_missing_translations = true
42
+ end
@@ -0,0 +1,11 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Version of your assets, change this if you want to expire all your assets.
4
+ Rails.application.config.assets.version = '1.0'
5
+
6
+ # Add additional assets to the asset load path
7
+ # Rails.application.config.assets.paths << Emoji.images_path
8
+
9
+ # Precompile additional assets.
10
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,59 @@
1
+ RailsRedshiftReplicator.setup do |config|
2
+ # RRR already provides a logger pointing to STDOUT, but you can point it to your own logger.
3
+ # Just be sure to make it inherit from RailsRedshiftReplicator::RLogger or you will loose
4
+ # the notifications feature.
5
+ # config.logger = MyLogger.new
6
+
7
+ # Connection parameters for Redshift. Defaults to environment variables.
8
+ config.redshift_connection_params = {
9
+ host: ENV['RRR_REDSHIFT_HOST'],
10
+ dbname: ENV['RRR_REDSHIFT_DATABASE'],
11
+ port: ENV['RRR_REDSHIFT_PORT'],
12
+ user: ENV['RRR_REDSHIFT_USER'],
13
+ password: ENV['RRR_REDSHIFT_PASSWORD']
14
+ }
15
+
16
+ # AWS S3 Replication bucket credentials. Defaults to environment variables.
17
+ config.aws_credentials = {
18
+ key: ENV['RRR_AWS_ACCESS_KEY_ID'],
19
+ secret: ENV['RRR_AWS_SECRET_ACCESS_KEY']
20
+ }
21
+
22
+ # AWS S3 replication bucket parameters.
23
+ # region defaults to environment variable or US East (N. Virginia)
24
+ # bucket defaults to environment variable
25
+ config.s3_bucket_params = {
26
+ region: (ENV['RRR_REPLICATION_REGION'] || 'us-east-1'),
27
+ bucket: ENV['RRR_REPLICATION_BUCKET'],
28
+ prefix: ENV['RRR_REPLICATION_PREFIX']
29
+ }
30
+
31
+ # Number of slices available on Redshift cluster. Used to split export files. Defaults to 1.
32
+ # see [http://docs.aws.amazon.com/redshift/latest/dg/t_splitting-data-files.html]
33
+ config.redshift_slices = 1
34
+
35
+ # Folder to store temporary replication files until the S3 upload. Defaults to /tmp
36
+ config.local_replication_path = '/tmp'
37
+
38
+ # Command or path to executable that splits files
39
+ config.split_command = 'split'
40
+
41
+ # Command or path to executable that compresses files to gzip
42
+ config.gzip_command = 'gzip'
43
+
44
+ # Enable debug mode to output messages to STDOUT. Default to false
45
+ config.debug_mode = false
46
+
47
+ # Defines how many replication records are kept in history. Default to nil keeping full history.
48
+ config.history_cap = nil
49
+
50
+ # Preferred format for export file
51
+ config.preferred_format = 'csv'
52
+
53
+ # Maximum number of retries for a replication before cancelling and starting another
54
+ config.max_retries = 5
55
+
56
+ # If deletes should be tracked and propagated to redshift
57
+ # Take a look at the "A word on tracking deletions" section
58
+ config.enable_delete_tracking = true
59
+ end
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,19 @@
1
+ en:
2
+ rails_redshift_replicator:
3
+ uploading_notice: "uploading %{file} to %{key}"
4
+ gzip_notice: "gzip %{file} to %{gzip_file} with command: %{command}"
5
+ exporting_results: "exporting %{counts} results"
6
+ importing_file: "importing %{file} to %{target_table}"
7
+ no_new_records: "No new records for %{table_name} to export"
8
+ missing_indexes: "'%{replication_field}' index is missing on table '%{table_name}'. Export performance can be improved by adding indexes to replication fields"
9
+ missing_table: "Coudn't find table %{table_name} on Redshift"
10
+ missing_replicator_type: Replication type not implemented
11
+ must_specify_tables: "Specify tables to export or use :all for all eligible tables"
12
+ replicable_added: "Added replicable for table '%{table_name}'"
13
+ executing_query: "Executing query with %{adapter}: %{sql}"
14
+ nothing_to_import: "No replication for table '%{table_name}' was pending import"
15
+ table_not_replicable: "The table '%{table_name}' is not registered as replicable"
16
+ max_retries_reached: "The replication #%{id} for table '%{table_name}' reached the maximum number of retries"
17
+ resuming_replication: "Resuming %{action} replication for table '%{table_name}', which was on %{state} state"
18
+ propagating_deletes: "Propagating %{count} deleted records from table '%{table_name}'"
19
+ delete_propagation_error: "Failed to propagate %{count} deleted records from table '%{table_name}'"
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+
3
+ mount RailsRedshiftReplicator::Engine => "/rails_redshift_replicator"
4
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 78a339d8e8dee9f70fd66fe18c31cf9e86f3fef9304059f98d18f6c913d5f4d62583f015a4dd523bf6341138f76e310536b073e866e3b291a283f6b4ae5c4fdc
15
+
16
+ test:
17
+ secret_key_base: c67fff4272bb077f550e70f5027315a620eafb1d1f1e7ec27790ea76142b3794658fcb07600fdd1883c44b7929968d493142091612fcb1d4ea5783d424db2104
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,40 @@
1
+ # Migration 20160504120421
2
+ class CreateTestTables < ActiveRecord::Migration
3
+ def up
4
+ create_table :users do |t|
5
+ t.string :login
6
+ t.string :password
7
+ t.integer :age
8
+ t.boolean :confirmed
9
+ t.timestamps null: false
10
+ end
11
+ add_index :users, [:login, :age]
12
+
13
+ create_table :posts do |t|
14
+ t.belongs_to :user
15
+ t.text :content
16
+ t.timestamps null: false
17
+ end
18
+ add_index :posts, [:user_id, :updated_at]
19
+
20
+ create_table :tags do |t|
21
+ t.string :name
22
+ t.timestamps null: false
23
+ end
24
+ add_index :tags, [:name, :updated_at]
25
+
26
+ create_table :tags_users, id: false do |t|
27
+ t.belongs_to :user
28
+ t.belongs_to :tag
29
+ end
30
+ add_index :tags_users, [:user_id, :tag_id]
31
+
32
+ end
33
+
34
+ def down
35
+ drop_table :users
36
+ drop_table :posts
37
+ drop_table :tags
38
+ drop_table :tags_users
39
+ end
40
+ end
@@ -0,0 +1,33 @@
1
+ # This migration was auto-generated via `rake db:generate_trigger_migration'.
2
+ # While you can edit this file, any changes you make to the definitions here
3
+ # will be undone by the next auto-generated trigger migration.
4
+
5
+ class CreateTriggersPostsDeleteOrTagsDeleteOrUsersDelete < ActiveRecord::Migration
6
+ def up
7
+ create_trigger("posts_after_delete_row_tr", :generated => true, :compatibility => 1).
8
+ on("posts").
9
+ after(:delete) do
10
+ "INSERT INTO rails_redshift_replicator_deleted_ids(source_table, object_id) VALUES('posts', OLD.id);"
11
+ end
12
+
13
+ create_trigger("tags_after_delete_row_tr", :generated => true, :compatibility => 1).
14
+ on("tags").
15
+ after(:delete) do
16
+ "INSERT INTO rails_redshift_replicator_deleted_ids(source_table, object_id) VALUES('tags', OLD.id);"
17
+ end
18
+
19
+ create_trigger("users_after_delete_row_tr", :generated => true, :compatibility => 1).
20
+ on("users").
21
+ after(:delete) do
22
+ "INSERT INTO rails_redshift_replicator_deleted_ids(source_table, object_id) VALUES('users', OLD.id);"
23
+ end
24
+ end
25
+
26
+ def down
27
+ drop_trigger("posts_after_delete_row_tr", "posts", :generated => true)
28
+
29
+ drop_trigger("tags_after_delete_row_tr", "tags", :generated => true)
30
+
31
+ drop_trigger("users_after_delete_row_tr", "users", :generated => true)
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ # This migration comes from rails_redshift_replicator (originally 20160503214955)
2
+ # 20160503214955
3
+ class CreateRailsRedshiftReplicatorReplications < ActiveRecord::Migration
4
+ def change
5
+ create_table :rails_redshift_replicator_replications do |t|
6
+ t.string "replication_type"
7
+ t.string "key"
8
+ t.string "state", :default => "enqueued"
9
+ t.string "last_record"
10
+ t.integer "retries", default: 0
11
+ t.text "last_error"
12
+ t.string "source_table"
13
+ t.string "target_table"
14
+ t.integer "slices"
15
+ t.string "first_record"
16
+ t.integer "record_count"
17
+ t.string "export_format"
18
+ t.integer "export_duration"
19
+ t.integer "upload_duration"
20
+ t.integer "import_duration"
21
+ t.datetime "created_at", :null => false
22
+ t.datetime "updated_at", :null => false
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ # This migration comes from rails_redshift_replicator (originally 20160509193335)
2
+ class CreateTableRailsRedshiftReplicatorDeletedIds < ActiveRecord::Migration
3
+ def change
4
+ create_table :rails_redshift_replicator_deleted_ids, id: false do |t|
5
+ t.string :source_table, index: true
6
+ t.integer :object_id
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,99 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20160511000938) do
15
+
16
+ # These are extensions that must be enabled in order to support this database
17
+ enable_extension "plpgsql"
18
+
19
+ create_table "posts", force: :cascade do |t|
20
+ t.integer "user_id"
21
+ t.text "content"
22
+ t.datetime "created_at", null: false
23
+ t.datetime "updated_at", null: false
24
+ end
25
+
26
+ add_index "posts", ["user_id", "updated_at"], name: "index_posts_on_user_id_and_updated_at", using: :btree
27
+
28
+ create_table "rails_redshift_replicator_deleted_ids", id: false, force: :cascade do |t|
29
+ t.string "source_table"
30
+ t.integer "object_id"
31
+ end
32
+
33
+ add_index "rails_redshift_replicator_deleted_ids", ["source_table"], name: "index_rails_redshift_replicator_deleted_ids_on_source_table", using: :btree
34
+
35
+ create_table "rails_redshift_replicator_replications", force: :cascade do |t|
36
+ t.string "replication_type"
37
+ t.string "key"
38
+ t.string "state", default: "enqueued"
39
+ t.string "last_record"
40
+ t.integer "retries", default: 0
41
+ t.text "last_error"
42
+ t.string "source_table"
43
+ t.string "target_table"
44
+ t.integer "slices"
45
+ t.string "first_record"
46
+ t.integer "record_count"
47
+ t.string "export_format"
48
+ t.integer "export_duration"
49
+ t.integer "upload_duration"
50
+ t.integer "import_duration"
51
+ t.datetime "created_at", null: false
52
+ t.datetime "updated_at", null: false
53
+ end
54
+
55
+ create_table "tags", force: :cascade do |t|
56
+ t.string "name"
57
+ t.datetime "created_at", null: false
58
+ t.datetime "updated_at", null: false
59
+ end
60
+
61
+ add_index "tags", ["name", "updated_at"], name: "index_tags_on_name_and_updated_at", using: :btree
62
+
63
+ create_table "tags_users", id: false, force: :cascade do |t|
64
+ t.integer "user_id"
65
+ t.integer "tag_id"
66
+ end
67
+
68
+ add_index "tags_users", ["user_id", "tag_id"], name: "index_tags_users_on_user_id_and_tag_id", using: :btree
69
+
70
+ create_table "users", force: :cascade do |t|
71
+ t.string "login"
72
+ t.string "password"
73
+ t.integer "age"
74
+ t.boolean "confirmed"
75
+ t.datetime "created_at", null: false
76
+ t.datetime "updated_at", null: false
77
+ end
78
+
79
+ add_index "users", ["login", "age"], name: "index_users_on_login_and_age", using: :btree
80
+
81
+ create_trigger("posts_after_delete_row_tr", :generated => true, :compatibility => 1).
82
+ on("posts").
83
+ after(:delete) do
84
+ "INSERT INTO rails_redshift_replicator_deleted_ids(source_table, object_id) VALUES('posts', OLD.id);"
85
+ end
86
+
87
+ create_trigger("tags_after_delete_row_tr", :generated => true, :compatibility => 1).
88
+ on("tags").
89
+ after(:delete) do
90
+ "INSERT INTO rails_redshift_replicator_deleted_ids(source_table, object_id) VALUES('tags', OLD.id);"
91
+ end
92
+
93
+ create_trigger("users_after_delete_row_tr", :generated => true, :compatibility => 1).
94
+ on("users").
95
+ after(:delete) do
96
+ "INSERT INTO rails_redshift_replicator_deleted_ids(source_table, object_id) VALUES('users', OLD.id);"
97
+ end
98
+
99
+ end