psql-cm 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.0.8 - 2012-04-23
2
+
3
+ Corrected error message.
4
+
5
+ Added overview to README as well as some clarifying changes.
6
+
7
+ Added submit examples to README.
8
+
1
9
  # 0.0.7 - 2012-04-20
2
10
 
3
11
  --database CLI option for specifying a single database name.
data/README.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # PostgreSQL Change Management Tool
2
2
 
3
+ ## Overview
4
+
5
+ Experienced software engineers and database administrators know very well that
6
+ database systems need care and feeding, especially as they grow over time.
7
+
8
+ A Database Change Management System (DB CMS) is one method of carefully
9
+ accounting for changes to live database schemas in a controlled manner with
10
+ full history and auditability of who changed what and when.
11
+
12
+ A DB CMS itself is a well documented process and is typically required to meet
13
+ the following criteria,
14
+
15
+ - Managed the deployment of changes to a schema, specifically the DDL and DML,
16
+ in a controlled and auditable manner
17
+
18
+ - Control the deployment / migration of DDL from one Server/Database/Schema to
19
+ another
20
+
21
+ - Integrate directly with the database system, backups and restores while
22
+ preserving the integrity of the data schema within the CMS
23
+
24
+ - Regenerate DDL for Disaster Recovery in the absence of database backups
25
+
26
+ psql-cm is a tool which was created to help make achieving these goals easier.
27
+
3
28
  ## What psql-cm is
4
29
 
5
30
  This project is a tool to assist with an ITIL like change management process
@@ -51,14 +76,14 @@ to separate multiple database names.
51
76
  Dump the current database schema to the specified --sql-path directory, if none
52
77
  specified it dumps to $PWD/sql
53
78
 
54
- $ psql-cm dump --database psqlcm_test
79
+ $ psql-cm dump --database psqlcm_test --sql-path $HOME/sql
55
80
 
56
81
  ## Restore
57
82
 
58
83
  Restore a previously psql-cm dumped database schema into a brand new postgresql
59
84
  database cluster.
60
85
 
61
- $ psql-cm restore --database psqlcm_test
86
+ $ psql-cm restore --database psqlcm_test --sql-path $HOME/sql
62
87
 
63
88
  ## Submit
64
89
 
@@ -155,8 +180,8 @@ a find command on \*nix:
155
180
  sql/psqlcm_test/schema_one.sql
156
181
  sql/psqlcm_test/schema_two.sql
157
182
 
158
- We can now do a restore restore by droping the database and then running the
159
- psql-cm restore action.
183
+ We can now do a restore by droping the database and then running the psql-cm
184
+ restore action.
160
185
 
161
186
  $ dropdb psqlcm_test
162
187
  $ psql-cm --database psqlcm_test restore
@@ -183,17 +208,24 @@ To play around inside of a running psql-cm Ruby environment use the console:
183
208
  The 'Walkthrough' from above is encoded as rake tasks, each step can be
184
209
  seen including all debugging output by running:
185
210
 
186
- rake clean # Remove the sql/ directory in the current working directory.
187
- rake create # Create the development database psqlcm_development, including two schemas.
188
- rake debug # Enable debugging using environment variable DEBUG
189
- rake drop # Drop the development database psqlcm_development
190
- rake dump # Remove sql/ from CWD and then run the psql-cm dump action on psqlcm_development
191
- rake build # Build the psql-cm gem.
192
- rake install # Build then install the psql-cm gem.
193
- rake restore # Create psqlcm_development, run psql-cm actions {setup, dump, restore} in order.
194
- rake setup # Create psqlcm_development and run psql-cm setup on it
211
+ rake build # Build the psql-cm gem
212
+ rake clean # Remove sql/ in the current working directory
213
+ rake console # Console, builds installs then runs console
214
+ rake create # Create database psqlcm_development, and two schemas
215
+ rake debug # Enable debugging using environment variable DEBUG
216
+ rake drop # Drop the database psqlcm_development
217
+ rake dump # Run psql-cm dump on psqlcm_development
218
+ rake install # Build then install the psql-cm gem
219
+ rake restore # Run psql-cm restore on psqlcm_development
220
+ rake setup # Run psql-cm setup on schemas within psqlcm_development
221
+ rake submit:file # Run psql-cm submit with a file based change
222
+ rake submit:string # Run psql-cm submit with a string change from cli
195
223
 
196
224
  Specifically to do a full-cycle walkthrough on the psqlcm\_development database,
197
225
 
198
- rake drop create setup dump drop restore
226
+ rake create setup dump drop restore submit:string submit:file
227
+
228
+ Then to re-run the full cycle we need to add 'drop' in the front,
229
+
230
+ rake drop create setup dump drop restore submit:string submit:file
199
231
 
@@ -12,7 +12,7 @@ module PSQLCM
12
12
 
13
13
  # Delegator to PG::Connection
14
14
  def __getobj__ ; @db end
15
- def __setobj__(object) ; end
15
+ def __setobj__(object) end
16
16
 
17
17
  def db
18
18
  unless @config[:dbname] == 'postgres'
@@ -23,10 +23,10 @@ module PSQLCM
23
23
  sh "psql #{db(database).psql_args} #{database} < #{cm_file}"
24
24
 
25
25
  ensure_cm_table_exists(database,schema)
26
- row = db(database).exec("SELECT content from #{schema}.#{config.cm_table}
26
+ Tempfile.open('base.sql') do |temp_file|
27
+ row = db(database).exec("SELECT content from #{schema}.#{config.cm_table}
27
28
  WHERE is_base IS true ORDER BY created_at
28
29
  DESC LIMIT 1;")
29
- Tempfile.open('base.sql') do |temp_file|
30
30
  temp_file.write(row)
31
31
  sh "psql #{db(database).psql_args} #{database} < #{temp_file.path}"
32
32
  end
@@ -4,7 +4,7 @@ module PSQLCM
4
4
  databases.each do |database|
5
5
  schemas(database).each do |schema|
6
6
  if config.change.to_s.empty?
7
- halt! "Content must be given! (--content=<file or \"sql string\">)"
7
+ halt! "Content must be given! (--change=<file or \"sql string\">)"
8
8
  elsif File.exists?(config.change)
9
9
  content = File.open(config.change, 'r') { |file| file.read }
10
10
  else # SQL String
@@ -25,18 +25,13 @@ module PSQLCM
25
25
  debug "submit> #{database}.#{schema}.#{config.cm_table}: #{config.change}"
26
26
  db(database).exec(
27
27
  "INSERT INTO #{schema}.#{config.cm_table}
28
- (is_base,implementer,content)
29
- VALUES (false,$1,$2)",
30
- [implementer,content]
31
- )
28
+ (is_base,implementer,content)
29
+ VALUES (false,$1,$2)",
30
+ [implementer,content]
31
+ )
32
32
  end # schemas
33
33
  end # databases
34
34
  end # def submit!
35
35
 
36
- private
37
-
38
- def validate(change)
39
-
40
- end
41
36
  end
42
37
  end
@@ -1,4 +1,4 @@
1
1
  module PSQLCM
2
- Version = '0.0.7'
2
+ Version = '0.0.8'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psql-cm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-20 00:00:00.000000000 Z
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: 1.3.6
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 1.8.22
71
+ rubygems_version: 1.8.23
72
72
  signing_key:
73
73
  specification_version: 3
74
74
  summary: PostgreSQL CM