Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9881 (new enhancement)

Opened 11 months ago

Last modified 10 months ago

[PATCH] [TEST] Short hand declaration style for lock_version

Reported by: lawrence Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: patch test
Cc:

Description

Like the shorthand notation for timestamps, add a short hand notation for lock_version for optimistic locking. E.g.:

    create_table :products do |t|
      t.lock_version
    end

This would add column lock_version as integer with default 0

Attachments

lock_version.patch (12.5 kB) - added by lawrence on 10/16/07 23:07:56.
sqlserver_lock_version.patch (1.0 kB) - added by lawrence on 10/16/07 23:12:57.
lock_version.2.patch (3.4 kB) - added by lawrence on 10/21/07 21:14:00.

Change History

10/15/07 23:12:55 changed by lawrence

This would add column lock_version as integer not nullable with default 0

10/16/07 23:07:56 changed by lawrence

  • attachment lock_version.patch added.

10/16/07 23:12:32 changed by lawrence

Added test: moved creation of people table from .sql files to schema.rb file. Note that the definition of the table is now:

  create_table :people, :force => true do |t|
    t.string :first_name    
    t.lock_version
  end

and that the existing locking_test.rb, method OptimisticLockingTest uses the lock_version column of table people.

Note: sqlserver_lock_version.patch must be patched against sqlserver adapter plugin.

10/16/07 23:12:57 changed by lawrence

  • attachment sqlserver_lock_version.patch added.

10/21/07 21:14:00 changed by lawrence

  • attachment lock_version.2.patch added.

10/21/07 21:15:58 changed by lawrence

Ignore first two patches, only consider: lock_version.2.patch. Adds migration test (similar to http://dev.rubyonrails.org/changeset/7973) and some documentation for methods timestamps and references.

10/25/07 23:44:42 changed by lawrence

  • keywords changed from patch to patch test.
  • summary changed from [PATCH] Short hand declaration style for lock_version to [PATCH] [TEST] Short hand declaration style for lock_version.