Module: QC::Setup

Defined in:
lib/queue_classic/setup.rb

Constant Summary collapse

Root =
File.expand_path("../..", File.dirname(__FILE__))
SqlFunctions =
File.join(Root, "/sql/ddl.sql")
CreateTable =
File.join(Root, "/sql/create_table.sql")
DropSqlFunctions =
File.join(Root, "/sql/drop_ddl.sql")
UpgradeTo_3_0_0 =
File.join(Root, "/sql/update_to_3_0_0.sql")
DowngradeFrom_3_0_0 =
File.join(Root, "/sql/downgrade_from_3_0_0.sql")
UpgradeTo_3_1_0 =
File.join(Root, "/sql/update_to_3_1_0.sql")
DowngradeFrom_3_1_0 =
File.join(Root, "/sql/downgrade_from_3_1_0.sql")
UpgradeTo_4_0_0 =
File.join(Root, "/sql/update_to_4_0_0.sql")
DowngradeFrom_4_0_0 =
File.join(Root, "/sql/downgrade_from_4_0_0.sql")

Class Method Summary collapse

Class Method Details

.create(c = QC::default_conn_adapter.connection) ⇒ Object



16
17
18
19
20
21
# File 'lib/queue_classic/setup.rb', line 16

def self.create(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute(File.read(CreateTable))
  conn.execute(File.read(SqlFunctions))
  conn.disconnect if c.nil? #Don't close a conn we didn't create.
end

.downgrade_from_3_0_0(c = QC::default_conn_adapter.connection) ⇒ Object



46
47
48
49
# File 'lib/queue_classic/setup.rb', line 46

def self.downgrade_from_3_0_0(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute(File.read(DowngradeFrom_3_0_0))
end

.downgrade_from_3_1_0(c = QC::default_conn_adapter.connection) ⇒ Object



58
59
60
61
# File 'lib/queue_classic/setup.rb', line 58

def self.downgrade_from_3_1_0(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute(File.read(DowngradeFrom_3_1_0))
end

.downgrade_from_4_0_0(c = QC::default_conn_adapter.connection) ⇒ Object



70
71
72
73
# File 'lib/queue_classic/setup.rb', line 70

def self.downgrade_from_4_0_0(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute(File.read(DowngradeFrom_4_0_0))
end

.drop(c = QC::default_conn_adapter.connection) ⇒ Object



23
24
25
26
27
28
# File 'lib/queue_classic/setup.rb', line 23

def self.drop(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute("DROP TABLE IF EXISTS queue_classic_jobs CASCADE")
  conn.execute(File.read(DropSqlFunctions))
  conn.disconnect if c.nil? #Don't close a conn we didn't create.
end

.update(c = QC::default_conn_adapter.connection) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/queue_classic/setup.rb', line 30

def self.update(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute(File.read(UpgradeTo_3_0_0))
  conn.execute(File.read(UpgradeTo_3_1_0))
  conn.execute(File.read(UpgradeTo_4_0_0))
  conn.execute(File.read(DropSqlFunctions))
  conn.execute(File.read(SqlFunctions))
end

.update_to_3_0_0(c = QC::default_conn_adapter.connection) ⇒ Object



39
40
41
42
43
44
# File 'lib/queue_classic/setup.rb', line 39

def self.update_to_3_0_0(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute(File.read(UpgradeTo_3_0_0))
  conn.execute(File.read(DropSqlFunctions))
  conn.execute(File.read(SqlFunctions))
end

.update_to_3_1_0(c = QC::default_conn_adapter.connection) ⇒ Object



51
52
53
54
55
56
# File 'lib/queue_classic/setup.rb', line 51

def self.update_to_3_1_0(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute(File.read(UpgradeTo_3_1_0))
  conn.execute(File.read(DropSqlFunctions))
  conn.execute(File.read(SqlFunctions))
end

.update_to_4_0_0(c = QC::default_conn_adapter.connection) ⇒ Object



63
64
65
66
67
68
# File 'lib/queue_classic/setup.rb', line 63

def self.update_to_4_0_0(c = QC::default_conn_adapter.connection)
  conn = QC::ConnAdapter.new(connection: c)
  conn.execute(File.read(UpgradeTo_4_0_0))
  conn.execute(File.read(DropSqlFunctions))
  conn.execute(File.read(SqlFunctions))
end