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 +9 -0
- data/lib/acts_as_versioned.rb +4 -1
- data/test/abstract_unit.rb +27 -8
- data/test/database.yml +18 -0
- data/test/migration_test.rb +2 -1
- data/test/schema.rb +43 -0
- data/test/versioned_test.rb +4 -4
- metadata +6 -31
- data/test/connections/native_db2/connection.rb +0 -14
- data/test/connections/native_mysql/connection.rb +0 -14
- data/test/connections/native_oci/connection.rb +0 -15
- data/test/connections/native_postgresql/connection.rb +0 -14
- data/test/connections/native_sqlite/connection.rb +0 -34
- data/test/connections/native_sqlite3/connection.rb +0 -33
- data/test/connections/native_sqlserver/connection.rb +0 -14
- data/test/connections/native_sqlserver_odbc/connection.rb +0 -15
- data/test/debug.log +0 -99
- data/test/fixtures/activerecord_versioned.sqlite +0 -0
- data/test/fixtures/activerecord_versioned.sqlite3 +0 -0
- data/test/fixtures/db_definitions/mysql.drop.sql +0 -4
- data/test/fixtures/db_definitions/mysql.sql +0 -36
- data/test/fixtures/db_definitions/postgresql.drop.sql +0 -4
- data/test/fixtures/db_definitions/postgresql.sql +0 -52
- data/test/fixtures/db_definitions/sqlite.drop.sql +0 -4
- data/test/fixtures/db_definitions/sqlite.sql +0 -32
- data/test/tests.rb +0 -2
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.
|
data/lib/acts_as_versioned.rb
CHANGED
@@ -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
|
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}"
|
data/test/abstract_unit.rb
CHANGED
@@ -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
|
10
|
-
|
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(
|
31
|
+
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
|
16
32
|
else
|
17
|
-
Fixtures.create_fixtures(
|
33
|
+
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
|
18
34
|
end
|
19
35
|
end
|
20
|
-
end
|
21
36
|
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
data/test/database.yml
ADDED
@@ -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
|
data/test/migration_test.rb
CHANGED
@@ -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"
|
data/test/schema.rb
ADDED
@@ -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
|
data/test/versioned_test.rb
CHANGED
@@ -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.
|
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.
|
7
|
-
date: 2005-
|
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/
|
33
|
-
- test/debug.log
|
32
|
+
- test/database.yml
|
34
33
|
- test/fixtures
|
35
34
|
- test/migration_test.rb
|
36
|
-
- test/
|
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/
|
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
|
-
)
|
data/test/debug.log
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# Logfile created on Thu Sep 29 08:57:24 CDT 2005 by logger.rb/1.5.2.4
|
2
|
-
[4;33mSQL (0.001227)[m [1;37mPRAGMA table_info(locked_pages)[m
|
3
|
-
[4;35mSQL (0.000842)[m [0;37mINSERT INTO locked_pages ('title', 'lock_version', 'type') VALUES('title', 1, NULL)[m
|
4
|
-
[4;33mSQL (0.001495)[m [1;37mPRAGMA table_info(locked_pages_revisions)[m
|
5
|
-
[4;35mSQL (0.001511)[m [0;37mINSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 08:57:25', NULL, 'title', 3, 1)[m
|
6
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001209)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version [m
|
7
|
-
[4;35mLockedPage Update with optimistic locking (0.002959)[m [0;37m UPDATE locked_pages
|
8
|
-
SET 'title' = 'title', 'type' = NULL, 'lock_version' = 2
|
9
|
-
WHERE id = 3 AND lock_version = 1
|
10
|
-
[m
|
11
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001171)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version [m
|
12
|
-
[4;35mLockedPage Update with optimistic locking (0.001465)[m [0;37m UPDATE locked_pages
|
13
|
-
SET 'title' = 'updated title', 'type' = NULL, 'lock_version' = 3
|
14
|
-
WHERE id = 3 AND lock_version = 2
|
15
|
-
[m
|
16
|
-
[4;33mSQL (0.001484)[m [1;37mINSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 08:57:25', NULL, 'updated title', 3, 3)[m
|
17
|
-
[4;35mSQL (0.000553)[m [0;37mDELETE FROM locked_pages_revisions WHERE version <= 1 AND page_id = 3[m
|
18
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001214)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version [m
|
19
|
-
[4;35mLockedPage Update with optimistic locking (0.001613)[m [0;37m UPDATE locked_pages
|
20
|
-
SET 'title' = 'updated title!', 'type' = NULL, 'lock_version' = 4
|
21
|
-
WHERE id = 3 AND lock_version = 3
|
22
|
-
[m
|
23
|
-
[4;33mSQL (0.001447)[m [1;37mINSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 08:57:25', NULL, 'updated title!', 3, 4)[m
|
24
|
-
[4;35mSQL (0.000522)[m [0;37mDELETE FROM locked_pages_revisions WHERE version <= 2 AND page_id = 3[m
|
25
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001439)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version [m
|
26
|
-
[4;33mSQL (0.001207)[m [1;37mPRAGMA table_info(locked_pages)[m
|
27
|
-
[4;35mSQL (0.000549)[m [0;37mINSERT INTO locked_pages ('title', 'lock_version', 'type') VALUES('title', 1, NULL)[m
|
28
|
-
[4;33mSQL (0.001507)[m [1;37mPRAGMA table_info(locked_pages_revisions)[m
|
29
|
-
[4;35mSQL (0.001516)[m [0;37mINSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 09:02:00', NULL, 'title', 3, 1)[m
|
30
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001315)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version [m
|
31
|
-
[4;35mLockedPage Update with optimistic locking (0.001660)[m [0;37m UPDATE locked_pages
|
32
|
-
SET 'title' = 'title', 'type' = NULL, 'lock_version' = 2
|
33
|
-
WHERE id = 3 AND lock_version = 1
|
34
|
-
[m
|
35
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001203)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 3 ORDER BY version [m
|
36
|
-
[4;35mLockedPage Update with optimistic locking (0.003941)[m [0;37m UPDATE locked_pages
|
37
|
-
SET 'title' = 'updated title', 'type' = NULL, 'lock_version' = 3
|
38
|
-
WHERE id = 3 AND lock_version = 2
|
39
|
-
[m
|
40
|
-
[4;33mSQL (0.001514)[m [1;37mINSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-29 09:02:12', NULL, 'updated title', 3, 3)[m
|
41
|
-
[4;35mSQL (0.000591)[m [0;37mDELETE FROM locked_pages_revisions WHERE version <= 1 AND page_id = 3[m
|
42
|
-
[4;33mLockedPage Update with optimistic locking (0.001470)[m [1;37m UPDATE locked_pages
|
43
|
-
SET 'title' = 'updated title', 'type' = NULL, 'lock_version' = 4
|
44
|
-
WHERE id = 3 AND lock_version = 3
|
45
|
-
[m
|
46
|
-
[4;35mSQL (0.000550)[m [0;37mDELETE FROM locked_pages_revisions WHERE version <= 2 AND page_id = 3[m
|
47
|
-
[4;33mLockedPage Load (0.001156)[m [1;37mSELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1[m
|
48
|
-
[4;35mSQL (0.001285)[m [0;37mPRAGMA table_info(locked_pages)[m
|
49
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Count (0.001063)[m [1;37mSELECT COUNT(*) FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 [m
|
50
|
-
[4;35mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001321)[m [0;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (title LIKE '%weblog%') ORDER BY version, version [m
|
51
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001450)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (title LIKE '%web%') ORDER BY version, version [m
|
52
|
-
[4;35mLockedPage Load (0.001090)[m [0;37mSELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1[m
|
53
|
-
[4;33mSQL (0.001236)[m [1;37mPRAGMA table_info(locked_pages)[m
|
54
|
-
[4;35mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.000906)[m [0;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 2 AND (title LIKE '%web%') ORDER BY version, version [m
|
55
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001316)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 ORDER BY version, version [m
|
56
|
-
[4;35mLockedPage Load (0.001179)[m [0;37mSELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1[m
|
57
|
-
[4;33mLockedPage Load (0.001558)[m [1;37mSELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1[m
|
58
|
-
[4;35mSpecialLockedPage Update with optimistic locking (0.001752)[m [0;37m UPDATE locked_pages
|
59
|
-
SET 'title' = 'fresh title', 'type' = 'SpecialLockedPage', 'lock_version' = 25
|
60
|
-
WHERE id = 2 AND lock_version = 24
|
61
|
-
[m
|
62
|
-
[4;33mSQL (0.001611)[m [1;37mPRAGMA table_info(locked_pages_revisions)[m
|
63
|
-
[4;35mSQL (0.001602)[m [0;37mINSERT INTO locked_pages_revisions ('updated_at', 'version_type', 'title', 'page_id', 'version') VALUES('2005-09-30 12:06:35', 'SpecialLockedPage', 'fresh title', 2, 25)[m
|
64
|
-
[4;33mSQL (0.000741)[m [1;37mDELETE FROM locked_pages_revisions WHERE version <= 23 AND page_id = 2[m
|
65
|
-
[4;35mActiveRecord::Acts::Versioned::LockedPageRevision Count (0.001129)[m [0;37mSELECT COUNT(*) FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 2 [m
|
66
|
-
[4;33mSpecialLockedPage Update with optimistic locking (0.001867)[m [1;37m UPDATE locked_pages
|
67
|
-
SET 'title' = 'stale title', 'type' = 'SpecialLockedPage', 'lock_version' = 25
|
68
|
-
WHERE id = 2 AND lock_version = 24
|
69
|
-
[m
|
70
|
-
[4;35mLockedPage Load (0.001088)[m [0;37mSELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1[m
|
71
|
-
[4;33mLockedPage Load (0.001127)[m [1;37mSELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1[m
|
72
|
-
[4;33mLockedPage Load (0.003112)[m [1;37mSELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1[m
|
73
|
-
[4;35mLockedPage Load (0.001110)[m [0;37mSELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1[m
|
74
|
-
[4;33mSQL (0.001694)[m [1;37mPRAGMA table_info(locked_pages)[m
|
75
|
-
[4;33mLockedPage Load (0.001492)[m [1;37mSELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1[m
|
76
|
-
[4;35mLockedPage Load (0.001084)[m [0;37mSELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1[m
|
77
|
-
[4;33mSQL (0.001457)[m [1;37mPRAGMA table_info(locked_pages)[m
|
78
|
-
[4;35mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001049)[m [0;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1[m
|
79
|
-
[4;33mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.035705)[m [1;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1[m
|
80
|
-
[4;35mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.000930)[m [0;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1[m
|
81
|
-
[4;33mLockedPage Load (0.001490)[m [1;37mSELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1[m
|
82
|
-
[4;35mLockedPage Load (0.001195)[m [0;37mSELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1[m
|
83
|
-
[4;33mSQL (0.001632)[m [1;37mPRAGMA table_info(locked_pages)[m
|
84
|
-
[4;35mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001005)[m [0;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1[m
|
85
|
-
[4;33mLockedPage Load (0.001169)[m [1;37mSELECT * FROM locked_pages WHERE locked_pages.id = 1 LIMIT 1[m
|
86
|
-
[4;35mLockedPage Load (0.001370)[m [0;37mSELECT * FROM locked_pages WHERE locked_pages.id = 2 LIMIT 1[m
|
87
|
-
[4;33mSQL (0.005599)[m [1;37mPRAGMA table_info(locked_pages)[m
|
88
|
-
[4;35mActiveRecord::Acts::Versioned::LockedPageRevision Load (0.001175)[m [0;37mSELECT * FROM locked_pages_revisions WHERE locked_pages_revisions.page_id = 1 AND (version = NULL) ORDER BY version, version LIMIT 1[m
|
89
|
-
[4;33mPage Load (0.002110)[m [1;37mSELECT * FROM pages WHERE pages.id = 1 LIMIT 1[m
|
90
|
-
[4;35mSQL (0.001568)[m [0;37mPRAGMA table_info(pages)[m
|
91
|
-
[4;33mActiveRecord::Acts::Versioned::PageVersion Load (0.001352)[m [1;37mSELECT * FROM page_versions WHERE page_versions.page_id = 1 ORDER BY version [m
|
92
|
-
[4;35mSQL (0.003145)[m [0;37mPRAGMA table_info(page_versions)[m
|
93
|
-
[4;33mActiveRecord::Acts::Versioned::PageVersion Load (0.001432)[m [1;37mSELECT * FROM page_versions WHERE page_versions.page_id = 1 AND (version = 23) ORDER BY version, version LIMIT 1[m
|
94
|
-
[4;35mPage Update (0.002421)[m [0;37mUPDATE 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[m
|
95
|
-
[4;33mPage Load (0.001187)[m [1;37mSELECT * FROM pages WHERE pages.id = 1 LIMIT 1[m
|
96
|
-
[4;35mSQL (0.001723)[m [0;37mPRAGMA table_info(pages)[m
|
97
|
-
[4;33mActiveRecord::Acts::Versioned::PageVersion Load (0.001722)[m [1;37mSELECT * FROM page_versions WHERE page_versions.page_id = 1 ORDER BY version [m
|
98
|
-
[4;35mSQL (0.001417)[m [0;37mPRAGMA table_info(page_versions)[m
|
99
|
-
[4;33mActiveRecord::Acts::Versioned::PageVersion Load (0.001533)[m [1;37mSELECT * FROM page_versions WHERE page_versions.page_id = 1 AND (version = 23) ORDER BY version LIMIT 1[m
|
Binary file
|
Binary file
|
@@ -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,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,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
|
-
);
|
data/test/tests.rb
DELETED