Class RR::ReplicationInitializer
In: lib/rubyrep/replication_initializer.rb
Parent: Object

Ensures all preconditions are met to start with replication

Methods

Constants

DIFF_DUMP_SIZE = 2000   Size of the replication log column diff_dump
DESCRIPTION_SIZE = 255   Size fo the event log column ‘description‘
LONG_DESCRIPTION_SIZE = 1000   Size of the event log column ‘long_description‘

Attributes

session  [RW]  The active Session

Public Class methods

Creates a new RepInititializer for the given Session

Public Instance methods

Calls the potentially provided :after_init handler after infrastructure tables are created.

Returns true if the change log exists in the specified database.

  • database: either :left or :right

Restores the original sequence settings for the named table. (Actually it sets the sequence increment to 1. If before, it had a different value, then the restoration will not be correct.)

  • database: either :left or :right
  • table_name: name of the table

Creates the change log table in the specified database

  • database: either :left or :right

Creates the replication log table.

Creates a trigger logging all table changes

  • database: either :left or :right
  • table: name of the table

Checks in both databases, if the activity_marker tables exist. If yes, drops them.

Drops the change log table in the specified database

  • database: either :left or :right

Checks in both databases, if the change_log tables exist. If yes, drops them.

Drops the replication log table.

Removes all rubyrep infrastructure tables from both databases.

Drops the replication trigger of the named table.

  • database: either :left or :right
  • table: name of the table

Checks in both databases, if the activity marker tables exist and if not, creates them.

Checks in both databases, if the change log tables exists and creates them if necessary

Checks if the event log table already exists and creates it if necessary

Checks in both databases, if the infrastructure tables (change log, event log) exist and creates them if necessary.

Ensures that the sequences of the named table (normally the primary key column) are generated with the correct increment and offset in both left and right database. The sequence is always updated in both databases.

  • table_pair: a hash of names of corresponding :left and :right tables
  • increment: increment of the sequence
  • left_offset: offset of table in left database
  • right_offset: offset of table in right database
  1. g. an increment of 2 and offset of 1 will lead to generation of odd

numbers.

Returns true if the replication log exists.

Adds to the current session‘s configuration an exclusion of rubyrep tables.

Returns the options for the given table. If table is nil, returns general options.

Prepares the database / tables for replication.

Checks for tables that have triggers but are not in the list of configured tables. Removes triggers and restores sequences of those tables.

  • configured_table_pairs: An array of table pairs (e. g. [{:left => ‘xy’, :right => ‘xy2’}]).

Ensures that create_table and related statements don‘t print notices to stdout. Then restored original message setting.

  • database: either :left or :right

Returns true if the replication trigger for the given table exists.

  • database: either :left or :right
  • table: name of the table

[Validate]