module TDP
Tiny Database Patcher.
Public Class Methods
Main entrypoint of TDP
package.
Initializes an Engine
with given database details and schema files locations and then calls the given block passing engine as a parameter.
- db
-
must be one of:
-
instance of Sequel::Database class
-
database URL that can be passed to Sequel.connect()
paths must be an array of names of .sql files and directories containing those files
# File lib/tdp.rb, line 502 def self.execute(db, paths = []) engine = Engine.new(db) paths.each { |x| engine << x } engine.bootstrap yield engine end
Returns true if argument is a valid file name of a patch.
To qualify for a patch, file name must end with “.sql” extension.
# File lib/tdp.rb, line 484 def self.patch_file?(filename) filename.end_with?('.sql') end
Returns true if argument is a valid file name of a permanent patch.
To qualify for a permanent patch, file name must start with a number and end with “.sql” extension. E.g. 001-initial-schema.sql or 201611001_add_accounts_table.sql
# File lib/tdp.rb, line 461 def self.permanent_patch_file?(filename) /^\d+.*\.sql$/ =~ filename end
Returns true if argument is a valid file name of a volatile patch.
To qualify for a volatile patch, file name must end with “.sql” exception and NOT start with a number (otherwise it'd qualify for permanent patch instead). E.g. views.sql or stored-procedures.sql
# File lib/tdp.rb, line 474 def self.volatile_patch_file?(filename) /^[^\d]+.*\.sql$/ =~ filename end