acts_as_versioned 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
1
+ *0.2.3*
2
+
3
+ * (12 Nov 2005) fixed bug with old behavior of #blank? [Michael Schuerig]
4
+ * (12 Nov 2005) updated tests to use ActiveRecord Schema
5
+
6
+ *0.2.2*
7
+
8
+ * (3 Nov 2005) added documentation note to #acts_as_versioned [Martin Jul]
9
+
1
10
  *0.2.1*
2
11
 
3
12
  * (6 Oct 2005) renamed dirty? to changed? to keep it uniform. it was aliased to keep it backwards compatible.
@@ -25,6 +25,9 @@ module ActiveRecord #:nodoc:
25
25
  # versioned table ready and that your model has a version field. This works with optimisic locking if the lock_version
26
26
  # column is present as well.
27
27
  #
28
+ # The class for the versioned model is derived the first time it is seen. Therefore, if you change your database schema you have to restart
29
+ # your container for the changes to be reflected. In development mode this usually means restarting WEBrick.
30
+ #
28
31
  # class Page < ActiveRecord::Base
29
32
  # # assumes pages_versions table
30
33
  # acts_as_versioned
@@ -180,7 +183,7 @@ module ActiveRecord #:nodoc:
180
183
  # Clears old revisions if a limit is set with the :limit option in <tt>acts_as_versioned</tt>.
181
184
  # Override this method to set your own criteria for clearing old versions.
182
185
  def clear_old_versions
183
- return if self.class.max_version_limit.blank?
186
+ return if self.class.max_version_limit == 0
184
187
  excess_baggage = send(self.class.version_column).to_i - self.class.max_version_limit
185
188
  if excess_baggage > 0
186
189
  sql = "DELETE FROM #{self.class.versioned_table_name} WHERE version <= #{excess_baggage} AND #{self.class.versioned_foreign_key} = #{self.id}"
@@ -6,20 +6,39 @@ require 'active_record'
6
6
  require 'active_record/fixtures'
7
7
  require 'active_support/binding_of_caller'
8
8
  require 'active_support/breakpoint'
9
- require 'connection'
10
- require 'acts_as_versioned'
9
+ require "#{File.dirname(__FILE__)}/../init"
10
+
11
+ config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
12
+ ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
13
+ ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite'])
14
+
15
+ load(File.dirname(__FILE__) + "/schema.rb")
16
+
17
+ # set up custom sequence on widget_versions for DBs that support sequences
18
+ if ENV['DB'] == 'postgresql'
19
+ ActiveRecord::Base.connection.execute "DROP SEQUENCE widgets_seq;" rescue nil
20
+ ActiveRecord::Base.connection.remove_column :widget_versions, :id
21
+ ActiveRecord::Base.connection.execute "CREATE SEQUENCE widgets_seq START 101;"
22
+ ActiveRecord::Base.connection.execute "ALTER TABLE widget_versions ADD COLUMN id INTEGER PRIMARY KEY DEFAULT nextval('widgets_seq');"
23
+ end
24
+
25
+ Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
26
+ $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
11
27
 
12
28
  class Test::Unit::TestCase #:nodoc:
13
29
  def create_fixtures(*table_names)
14
30
  if block_given?
15
- Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures/", table_names) { yield }
31
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
16
32
  else
17
- Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures/", table_names)
33
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
18
34
  end
19
35
  end
20
- end
21
36
 
22
- Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
23
- Test::Unit::TestCase.use_instantiated_fixtures = false
24
- Test::Unit::TestCase.use_transactional_fixtures = (ENV['AR_TX_FIXTURES'] == "yes")
37
+ # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
38
+ self.use_transactional_fixtures = true
39
+
40
+ # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
41
+ self.use_instantiated_fixtures = false
25
42
 
43
+ # Add more helper methods to be used by all tests here...
44
+ end
@@ -0,0 +1,18 @@
1
+ sqlite:
2
+ :adapter: sqlite
3
+ :dbfile: acts_as_versioned_plugin.sqlite.db
4
+ sqlite3:
5
+ :adapter: sqlite3
6
+ :dbfile: acts_as_versioned_plugin.sqlite3.db
7
+ postgresql:
8
+ :adapter: postgresql
9
+ :username: postgres
10
+ :password: postgres
11
+ :database: acts_as_versioned_plugin_test
12
+ :min_messages: ERROR
13
+ mysql:
14
+ :adapter: mysql
15
+ :host: localhost
16
+ :username: rails
17
+ :password:
18
+ :database: acts_as_versioned_plugin_test
@@ -1,4 +1,4 @@
1
- require 'abstract_unit'
1
+ require File.join(File.dirname(__FILE__), 'abstract_unit')
2
2
 
3
3
  if ActiveRecord::Base.connection.supports_migrations?
4
4
  class Thing < ActiveRecord::Base
@@ -7,6 +7,7 @@ if ActiveRecord::Base.connection.supports_migrations?
7
7
  end
8
8
 
9
9
  class MigrationTest < Test::Unit::TestCase
10
+ self.use_transactional_fixtures = false
10
11
  def teardown
11
12
  ActiveRecord::Base.connection.initialize_schema_information
12
13
  ActiveRecord::Base.connection.update "UPDATE schema_info SET version = 0"
@@ -0,0 +1,43 @@
1
+ ActiveRecord::Schema.define(:version => 0) do
2
+ create_table :pages, :force => true do |t|
3
+ t.column :version, :integer
4
+ t.column :title, :string, :limit => 255
5
+ t.column :body, :text
6
+ t.column :updated_on, :datetime
7
+ end
8
+
9
+ create_table :page_versions, :force => true do |t|
10
+ t.column :page_id, :integer
11
+ t.column :version, :integer
12
+ t.column :title, :string, :limit => 255
13
+ t.column :body, :text
14
+ t.column :updated_on, :datetime
15
+ end
16
+
17
+ create_table :locked_pages, :force => true do |t|
18
+ t.column :lock_version, :integer
19
+ t.column :title, :string, :limit => 255
20
+ t.column :type, :string, :limit => 255
21
+ end
22
+
23
+ create_table :locked_pages_revisions, :force => true do |t|
24
+ t.column :page_id, :integer
25
+ t.column :version, :integer
26
+ t.column :title, :string, :limit => 255
27
+ t.column :version_type, :string, :limit => 255
28
+ t.column :updated_at, :datetime
29
+ end
30
+
31
+ create_table :widgets, :force => true do |t|
32
+ t.column :name, :string, :limit => 50
33
+ t.column :version, :integer
34
+ t.column :updated_at, :datetime
35
+ end
36
+
37
+ create_table :widget_versions, :force => true do |t|
38
+ t.column :widget_id, :integer
39
+ t.column :name, :string, :limit => 50
40
+ t.column :version, :integer
41
+ t.column :updated_at, :datetime
42
+ end
43
+ end
@@ -1,6 +1,6 @@
1
- require 'abstract_unit'
2
- require 'fixtures/page'
3
- require 'fixtures/widget'
1
+ require File.join(File.dirname(__FILE__), 'abstract_unit')
2
+ require File.join(File.dirname(__FILE__), 'fixtures/page')
3
+ require File.join(File.dirname(__FILE__), 'fixtures/widget')
4
4
 
5
5
  class VersionedTest < Test::Unit::TestCase
6
6
  fixtures :pages, :page_versions, :locked_pages, :locked_pages_revisions
@@ -233,6 +233,6 @@ class VersionedTest < Test::Unit::TestCase
233
233
  Widget.create :name => 'new widget'
234
234
  Widget.create :name => 'new widget'
235
235
  assert_equal 3, Widget.count
236
- assert_equal 3, Widget.versions.size
236
+ assert_equal 3, Widget.versioned_class.count
237
237
  end
238
238
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: acts_as_versioned
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
7
- date: 2005-10-06
6
+ version: 0.2.3
7
+ date: 2005-11-13
8
8
  summary: Simple versioning with active record models
9
9
  require_paths:
10
10
  - lib
@@ -29,31 +29,11 @@ authors:
29
29
  files:
30
30
  - lib/acts_as_versioned.rb
31
31
  - test/abstract_unit.rb
32
- - test/connections
33
- - test/debug.log
32
+ - test/database.yml
34
33
  - test/fixtures
35
34
  - test/migration_test.rb
36
- - test/tests.rb
35
+ - test/schema.rb
37
36
  - test/versioned_test.rb
38
- - test/connections/native_db2
39
- - test/connections/native_mysql
40
- - test/connections/native_oci
41
- - test/connections/native_postgresql
42
- - test/connections/native_sqlite
43
- - test/connections/native_sqlite3
44
- - test/connections/native_sqlserver
45
- - test/connections/native_sqlserver_odbc
46
- - test/connections/native_db2/connection.rb
47
- - test/connections/native_mysql/connection.rb
48
- - test/connections/native_oci/connection.rb
49
- - test/connections/native_postgresql/connection.rb
50
- - test/connections/native_sqlite/connection.rb
51
- - test/connections/native_sqlite3/connection.rb
52
- - test/connections/native_sqlserver/connection.rb
53
- - test/connections/native_sqlserver_odbc/connection.rb
54
- - test/fixtures/activerecord_versioned.sqlite
55
- - test/fixtures/activerecord_versioned.sqlite3
56
- - test/fixtures/db_definitions
57
37
  - test/fixtures/locked_pages.yml
58
38
  - test/fixtures/locked_pages_revisions.yml
59
39
  - test/fixtures/migrations
@@ -61,19 +41,14 @@ files:
61
41
  - test/fixtures/page_versions.yml
62
42
  - test/fixtures/pages.yml
63
43
  - test/fixtures/widget.rb
64
- - test/fixtures/db_definitions/mysql.drop.sql
65
- - test/fixtures/db_definitions/mysql.sql
66
- - test/fixtures/db_definitions/postgresql.drop.sql
67
- - test/fixtures/db_definitions/postgresql.sql
68
- - test/fixtures/db_definitions/sqlite.drop.sql
69
- - test/fixtures/db_definitions/sqlite.sql
70
44
  - test/fixtures/migrations/1_add_versioned_tables.rb
71
45
  - README
72
46
  - MIT-LICENSE
73
47
  - CHANGELOG
74
48
  - RUNNING_UNIT_TESTS
75
49
  test_files:
76
- - test/tests.rb
50
+ - test/migration_test.rb
51
+ - test/versioned_test.rb
77
52
  rdoc_options: []
78
53
  extra_rdoc_files: []
79
54
  executables: []
@@ -1,14 +0,0 @@
1
- print "Using native DB2\n"
2
- require 'logger'
3
-
4
- ActiveRecord::Base.logger = Logger.new("debug.log")
5
-
6
- db1 = 'arversioned'
7
-
8
- ActiveRecord::Base.establish_connection(
9
- :adapter => "db2",
10
- :host => "localhost",
11
- :username => "arunit",
12
- :password => "arunit",
13
- :database => db1
14
- )
@@ -1,14 +0,0 @@
1
- print "Using native MySQL\n"
2
- require 'logger'
3
-
4
- ActiveRecord::Base.logger = Logger.new("debug.log")
5
-
6
- db1 = 'activerecord_versioned'
7
-
8
- ActiveRecord::Base.establish_connection(
9
- :adapter => "mysql",
10
- :host => "localhost",
11
- :username => "rails",
12
- :password => "",
13
- :database => db1
14
- )
@@ -1,15 +0,0 @@
1
- print "Using OCI Oracle\n"
2
- require 'logger'
3
-
4
- ActiveRecord::Base.logger = Logger.new STDOUT
5
- ActiveRecord::Base.logger.level = Logger::WARN
6
-
7
- db1 = 'activerecord_versioned'
8
-
9
- ActiveRecord::Base.establish_connection(
10
- :adapter => 'oci',
11
- :host => '', # can use an oracle SID
12
- :username => 'arunit',
13
- :password => 'arunit',
14
- :database => db1
15
- )
@@ -1,14 +0,0 @@
1
- print "Using native PostgreSQL\n"
2
- require 'logger'
3
-
4
- ActiveRecord::Base.logger = Logger.new("debug.log")
5
-
6
- db1 = 'activerecord_versioned'
7
-
8
- ActiveRecord::Base.establish_connection(
9
- :adapter => "postgresql",
10
- :host => nil,
11
- :username => "postgres",
12
- :password => "postgres",
13
- :database => db1
14
- )
@@ -1,34 +0,0 @@
1
- print "Using native SQlite\n"
2
- require 'logger'
3
- ActiveRecord::Base.logger = Logger.new("debug.log")
4
-
5
- class SqliteError < StandardError
6
- end
7
-
8
- BASE_DIR = File.expand_path(File.dirname(__FILE__) + '/../../fixtures')
9
- sqlite_test_db = "#{BASE_DIR}/activerecord_versioned.sqlite"
10
-
11
- def make_connection(clazz, db_file, db_definitions_file)
12
- unless File.exist?(db_file)
13
- puts "SQLite database not found at #{db_file}. Rebuilding it."
14
- sqlite_command = %Q{sqlite #{db_file} "create table a (a integer); drop table a;"}
15
- puts "Executing '#{sqlite_command}'"
16
- raise SqliteError.new("Seems that there is no sqlite executable available") unless system(sqlite_command)
17
- clazz.establish_connection(
18
- :adapter => "sqlite",
19
- :dbfile => db_file)
20
- script = File.read("#{BASE_DIR}/db_definitions/#{db_definitions_file}")
21
- # SQLite-Ruby has problems with semi-colon separated commands, so split and execute one at a time
22
- script.split(';').each do
23
- |command|
24
- clazz.connection.execute(command) unless command.strip.empty?
25
- end
26
- else
27
- clazz.establish_connection(
28
- :adapter => "sqlite",
29
- :dbfile => db_file)
30
- end
31
- end
32
-
33
- make_connection(ActiveRecord::Base, sqlite_test_db, 'sqlite.sql')
34
-
@@ -1,33 +0,0 @@
1
- print "Using native SQLite3\n"
2
- require 'logger'
3
- ActiveRecord::Base.logger = Logger.new("debug.log")
4
-
5
- class SqliteError < StandardError
6
- end
7
-
8
- BASE_DIR = File.expand_path(File.dirname(__FILE__) + '/../../fixtures')
9
- sqlite_test_db = "#{BASE_DIR}/activerecord_versioned.sqlite3"
10
-
11
- def make_connection(clazz, db_file, db_definitions_file)
12
- unless File.exist?(db_file)
13
- puts "SQLite3 database not found at #{db_file}. Rebuilding it."
14
- sqlite_command = %Q{sqlite3 #{db_file} "create table a (a integer); drop table a;"}
15
- puts "Executing '#{sqlite_command}'"
16
- raise SqliteError.new("Seems that there is no sqlite3 executable available") unless system(sqlite_command)
17
- clazz.establish_connection(
18
- :adapter => "sqlite3",
19
- :dbfile => db_file)
20
- script = File.read("#{BASE_DIR}/db_definitions/#{db_definitions_file}")
21
- # SQLite-Ruby has problems with semi-colon separated commands, so split and execute one at a time
22
- script.split(';').each do
23
- |command|
24
- clazz.connection.execute(command) unless command.strip.empty?
25
- end
26
- else
27
- clazz.establish_connection(
28
- :adapter => "sqlite3",
29
- :dbfile => db_file)
30
- end
31
- end
32
-
33
- make_connection(ActiveRecord::Base, sqlite_test_db, 'sqlite.sql')
@@ -1,14 +0,0 @@
1
- print "Using native SQLServer\n"
2
- require 'logger'
3
-
4
- ActiveRecord::Base.logger = Logger.new("debug.log")
5
-
6
- db1 = 'activerecord_versioned'
7
-
8
- ActiveRecord::Base.establish_connection(
9
- :adapter => "sqlserver",
10
- :host => "localhost",
11
- :username => "sa",
12
- :password => "",
13
- :database => db1
14
- )
@@ -1,15 +0,0 @@
1
- print "Using native SQLServer via ODBC\n"
2
- require 'logger'
3
-
4
- ActiveRecord::Base.logger = Logger.new("debug.log")
5
-
6
- dsn1 = 'activerecord_versioned'
7
-
8
- ActiveRecord::Base.establish_connection(
9
- :adapter => "sqlserver",
10
- :mode => "ODBC",
11
- :host => "localhost",
12
- :username => "sa",
13
- :password => "",
14
- :dsn => dsn1
15
- )
@@ -1,99 +0,0 @@
1
- # Logfile created on Thu Sep 29 08:57:24 CDT 2005 by logger.rb/1.5.2.4
2
- SQL (0.001227) PRAGMA table_info(locked_pages)
3
- SQL (0.000842) INSERT INTO locked_pages ('title', 'lock_version', 'type') VALUES('title', 1, NULL)
4
- SQL (0.001495) PRAGMA table_info(locked_pages_revisions)
5
- SQL (0.001511) INSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 08:57:25', NULL, 'title', 3, 1)
6
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001209) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version 
7
- LockedPage Update with optimistic locking (0.002959)  UPDATE locked_pages
8
- SET 'title' = 'title', 'type' = NULL, 'lock_version' = 2
9
- WHERE id = 3 AND lock_version = 1
10
- 
11
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001171) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version 
12
- LockedPage Update with optimistic locking (0.001465)  UPDATE locked_pages
13
- SET 'title' = 'updated title', 'type' = NULL, 'lock_version' = 3
14
- WHERE id = 3 AND lock_version = 2
15
- 
16
- SQL (0.001484) INSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 08:57:25', NULL, 'updated title', 3, 3)
17
- SQL (0.000553) DELETE FROM locked_pages_revisions WHERE version <= 1 AND page_id = 3
18
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001214) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version 
19
- LockedPage Update with optimistic locking (0.001613)  UPDATE locked_pages
20
- SET 'title' = 'updated title!', 'type' = NULL, 'lock_version' = 4
21
- WHERE id = 3 AND lock_version = 3
22
- 
23
- SQL (0.001447) INSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 08:57:25', NULL, 'updated title!', 3, 4)
24
- SQL (0.000522) DELETE FROM locked_pages_revisions WHERE version <= 2 AND page_id = 3
25
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001439) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version 
26
- SQL (0.001207) PRAGMA table_info(locked_pages)
27
- SQL (0.000549) INSERT INTO locked_pages ('title', 'lock_version', 'type') VALUES('title', 1, NULL)
28
- SQL (0.001507) PRAGMA table_info(locked_pages_revisions)
29
- SQL (0.001516) INSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 09:02:00', NULL, 'title', 3, 1)
30
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001315) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version 
31
- LockedPage Update with optimistic locking (0.001660)  UPDATE locked_pages
32
- SET 'title' = 'title', 'type' = NULL, 'lock_version' = 2
33
- WHERE id = 3 AND lock_version = 1
34
- 
35
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001203) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version 
36
- LockedPage Update with optimistic locking (0.003941)  UPDATE locked_pages
37
- SET 'title' = 'updated title', 'type' = NULL, 'lock_version' = 3
38
- WHERE id = 3 AND lock_version = 2
39
- 
40
- SQL (0.001514) INSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 09:02:12', NULL, 'updated title', 3, 3)
41
- SQL (0.000591) DELETE FROM locked_pages_revisions WHERE version <= 1 AND page_id = 3
42
- LockedPage Update with optimistic locking (0.001470)  UPDATE locked_pages
43
- SET 'title' = 'updated title', 'type' = NULL, 'lock_version' = 4
44
- WHERE id = 3 AND lock_version = 3
45
- 
46
- SQL (0.000550) DELETE FROM locked_pages_revisions WHERE version <= 2 AND page_id = 3
47
- LockedPage Load (0.001156) SELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1
48
- SQL (0.001285) PRAGMA table_info(locked_pages)
49
- ActiveRecord::Acts::Versioned::LockedPageRevision Count (0.001063) SELECT COUNT(*) FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 
50
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001321) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (title LIKE '%weblog%') ORDER BY version, version 
51
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001450) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (title LIKE '%web%') ORDER BY version, version 
52
- LockedPage Load (0.001090) SELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1
53
- SQL (0.001236) PRAGMA table_info(locked_pages)
54
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.000906) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 2 AND (title LIKE '%web%') ORDER BY version, version 
55
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001316) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 ORDER BY version, version 
56
- LockedPage Load (0.001179) SELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1
57
- LockedPage Load (0.001558) SELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1
58
- SpecialLockedPage Update with optimistic locking (0.001752)  UPDATE locked_pages
59
- SET 'title' = 'fresh title', 'type' = 'SpecialLockedPage', 'lock_version' = 25
60
- WHERE id = 2 AND lock_version = 24
61
- 
62
- SQL (0.001611) PRAGMA table_info(locked_pages_revisions)
63
- SQL (0.001602) INSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-30 12:06:35', 'SpecialLockedPage', 'fresh title', 2, 25)
64
- SQL (0.000741) DELETE FROM locked_pages_revisions WHERE version <= 23 AND page_id = 2
65
- ActiveRecord::Acts::Versioned::LockedPageRevision Count (0.001129) SELECT COUNT(*) FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 2 
66
- SpecialLockedPage Update with optimistic locking (0.001867)  UPDATE locked_pages
67
- SET 'title' = 'stale title', 'type' = 'SpecialLockedPage', 'lock_version' = 25
68
- WHERE id = 2 AND lock_version = 24
69
- 
70
- LockedPage Load (0.001088) SELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1
71
- LockedPage Load (0.001127) SELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1
72
- LockedPage Load (0.003112) SELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1
73
- LockedPage Load (0.001110) SELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1
74
- SQL (0.001694) PRAGMA table_info(locked_pages)
75
- LockedPage Load (0.001492) SELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1
76
- LockedPage Load (0.001084) SELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1
77
- SQL (0.001457) PRAGMA table_info(locked_pages)
78
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001049) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1
79
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.035705) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1
80
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.000930) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1
81
- LockedPage Load (0.001490) SELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1
82
- LockedPage Load (0.001195) SELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1
83
- SQL (0.001632) PRAGMA table_info(locked_pages)
84
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001005) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1
85
- LockedPage Load (0.001169) SELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1
86
- LockedPage Load (0.001370) SELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1
87
- SQL (0.005599) PRAGMA table_info(locked_pages)
88
- ActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001175) SELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1
89
- Page Load (0.002110) SELECT * FROM pages WHERE pages.id = 1 LIMIT 1
90
- SQL (0.001568) PRAGMA table_info(pages)
91
- ActiveRecord::Acts::Versioned::PageVersion Load (0.001352) SELECT * FROM page_versions WHERE page_versions.page_id = 1 ORDER BY version 
92
- SQL (0.003145) PRAGMA table_info(page_versions)
93
- ActiveRecord::Acts::Versioned::PageVersion Load (0.001432) SELECT * FROM page_versions WHERE page_versions.page_id = 1 AND (version = 23) ORDER BY version, version LIMIT 1
94
- Page Update (0.002421) UPDATE pages SET 'updated_on' = '2005-09-30 12:11:01', 'body' = 'Such a lovely day', 'version' = 23, 'title' = 'Welcome to the weblg' WHERE id = 1
95
- Page Load (0.001187) SELECT * FROM pages WHERE pages.id = 1 LIMIT 1
96
- SQL (0.001723) PRAGMA table_info(pages)
97
- ActiveRecord::Acts::Versioned::PageVersion Load (0.001722) SELECT * FROM page_versions WHERE page_versions.page_id = 1 ORDER BY version 
98
- SQL (0.001417) PRAGMA table_info(page_versions)
99
- ActiveRecord::Acts::Versioned::PageVersion Load (0.001533) SELECT * FROM page_versions WHERE page_versions.page_id = 1 AND (version = 23) ORDER BY version LIMIT 1
@@ -1,4 +0,0 @@
1
- DROP TABLE pages;
2
- DROP TABLE page_versions;
3
- DROP TABLE locked_pages;
4
- DROP TABLE locked_pages_revisions;
@@ -1,36 +0,0 @@
1
- CREATE TABLE `pages` (
2
- `id` int(11) NOT NULL auto_increment,
3
- `version` int(11) default NULL,
4
- `title` varchar(255) default NULL,
5
- `body` TEXT NOT NULL,
6
- `updated_on` datetime default NULL,
7
- PRIMARY KEY (`id`)
8
- ) TYPE=InnoDB;
9
-
10
- CREATE TABLE `page_versions` (
11
- `id` int(11) NOT NULL auto_increment,
12
- `page_id` int(11) default NULL,
13
- `version` int(11) default NULL,
14
- `title` varchar(255) default NULL,
15
- `body` TEXT NOT NULL,
16
- `updated_on` datetime default NULL,
17
- PRIMARY KEY (`id`)
18
- ) TYPE=InnoDB;
19
-
20
- CREATE TABLE `locked_pages` (
21
- `id` int(11) NOT NULL auto_increment,
22
- `lock_version` int(11) default NULL,
23
- `title` varchar(255) default NULL,
24
- `type` varchar(255) default NULL,
25
- PRIMARY KEY (`id`)
26
- ) TYPE=InnoDB;
27
-
28
- CREATE TABLE `locked_pages_revisions` (
29
- `id` int(11) NOT NULL auto_increment,
30
- `page_id` int(11) default NULL,
31
- `version` int(11) default NULL,
32
- `title` varchar(255) default NULL,
33
- `version_type` varchar(255) default NULL,
34
- `updated_at` datetime default NULL,
35
- PRIMARY KEY (`id`)
36
- ) TYPE=InnoDB;
@@ -1,4 +0,0 @@
1
- DROP TABLE pages;
2
- DROP TABLE page_versions;
3
- DROP TABLE locked_pages;
4
- DROP TABLE locked_pages_revisions;
@@ -1,52 +0,0 @@
1
- CREATE TABLE pages (
2
- id SERIAL,
3
- version INTEGER,
4
- title VARCHAR(255),
5
- body TEXT,
6
- updated_on TIMESTAMP
7
- );
8
- SELECT setval('pages_id_seq', 100);
9
-
10
- CREATE TABLE page_versions (
11
- id SERIAL,
12
- page_id INTEGER,
13
- version INTEGER,
14
- title VARCHAR(255),
15
- body TEXT,
16
- updated_on TIMESTAMP
17
- );
18
-
19
- CREATE TABLE locked_pages (
20
- id SERIAL,
21
- lock_version INTEGER,
22
- title VARCHAR(255),
23
- type VARCHAR(255)
24
- );
25
- SELECT setval('pages_id_seq', 100);
26
-
27
- CREATE TABLE locked_pages_revisions (
28
- id SERIAL,
29
- page_id INTEGER,
30
- version INTEGER,
31
- title VARCHAR(255),
32
- version_type VARCHAR(255),
33
- updated_at TIMESTAMP
34
- );
35
-
36
- CREATE TABLE widgets (
37
- id SERIAL,
38
- name VARCHAR(50),
39
- version INTEGER,
40
- updated_at TIMESTAMP
41
- );
42
-
43
- CREATE SEQUENCE widgets_seq START 101;
44
-
45
- CREATE TABLE widget_versions (
46
- id INTEGER DEFAULT nextval('widgets_seq'),
47
- widget_id INTEGER,
48
- name VARCHAR(50),
49
- version INTEGER,
50
- updated_at TIMESTAMP,
51
- PRIMARY KEY (id)
52
- );
@@ -1,4 +0,0 @@
1
- DROP TABLE pages;
2
- DROP TABLE page_versions;
3
- DROP TABLE locked_pages;
4
- DROP TABLE locked_pages_revisions;
@@ -1,32 +0,0 @@
1
- CREATE TABLE 'pages' (
2
- 'id' INTEGER NOT NULL PRIMARY KEY,
3
- 'version' INTEGER,
4
- 'title' VARCHAR(255),
5
- 'body' TEXT,
6
- 'updated_on' DATETIME DEFAULT NULL
7
- );
8
-
9
- CREATE TABLE 'page_versions' (
10
- 'id' INTEGER NOT NULL PRIMARY KEY,
11
- 'page_id' INTEGER NOT NULL,
12
- 'version' INTEGER NOT NULL,
13
- 'title' VARCHAR(255),
14
- 'body' TEXT DEFAULT NULL,
15
- 'updated_on' DATETIME DEFAULT NULL
16
- );
17
-
18
- CREATE TABLE 'locked_pages' (
19
- 'id' INTEGER NOT NULL PRIMARY KEY,
20
- 'lock_version' INTEGER NOT NULL,
21
- 'title' VARCHAR(255),
22
- 'type' VARCHAR(255)
23
- );
24
-
25
- CREATE TABLE 'locked_pages_revisions' (
26
- 'id' INTEGER NOT NULL PRIMARY KEY,
27
- 'page_id' INTEGER NOT NULL,
28
- 'version' INTEGER NOT NULL,
29
- 'title' VARCHAR(255),
30
- 'version_type' VARCHAR(255),
31
- 'updated_at' DATETIME DEFAULT NULL
32
- );
@@ -1,2 +0,0 @@
1
- $:.unshift "../lib"
2
- Dir["**/*_test.rb"].each { |f| load f }