Sha256: 825e79f2b8c212431c93321636a2fb6b2633ccf120f392f6df3a5c147cef5dc2

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require "pp"
require "pathname"
root_path = Pathname(__FILE__).dirname.join("..").expand_path
lib_path  = root_path.join("lib")
$:.unshift(lib_path)

require "active_record"

attempts = 0
begin
  ActiveRecord::Base.establish_connection({
    adapter: "mysql2",
    database: "github_ds_test",
  })
  ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS `key_values`")
  require "generators/github/ds/templates/migration"
  ActiveRecord::Migration.verbose = false
  CreateKeyValuesTable.up
rescue ActiveRecord::NoDatabaseError
  raise if attempts >= 1
  ActiveRecord::Base.establish_connection({
    adapter: "mysql2",
  })
  ActiveRecord::Base.connection.execute("CREATE DATABASE `github_ds_test`")
  attempts += 1
  retry
end

ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS `example_key_values`")
ActiveRecord::Base.connection.execute(<<-SQL)
  CREATE TABLE `example_key_values` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `key` varchar(255) NOT NULL,
    `value` blob NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `index_key_values_on_key` (`key`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
SQL

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github-ds-0.1.0 examples/example_setup.rb