Ticket #9881: lock_version.patch
| File lock_version.patch, 12.5 kB (added by lawrence, 1 year ago) |
|---|
-
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
old new 375 375 # What can be written like this with the regular calls to column: 376 376 # 377 377 # create_table "products", :force => true do |t| 378 # t.column "shop_id", :integer 379 # t.column "creator_id", :integer 380 # t.column "name", :string, :default => "Untitled" 381 # t.column "value", :string, :default => "Untitled" 382 # t.column "created_at", :datetime 383 # t.column "updated_at", :datetime 378 # t.column "shop_id", :integer 379 # t.column "creator_id", :integer 380 # t.column "name", :string, :default => "Untitled" 381 # t.column "value", :string, :default => "Untitled" 382 # t.column "lock_version", :integer, {:default => 0, :null => false} 383 # t.column "created_at", :datetime 384 # t.column "updated_at", :datetime 384 385 # end 385 386 # 386 387 # Can also be written as follows using the short-hand: … … 388 389 # create_table :products do |t| 389 390 # t.integer :shop_id, :creator_id 390 391 # t.string :name, :value, :default => "Untitled" 392 # t.lock_version 391 393 # t.timestamps 392 394 # end 393 395 # 394 396 # There's a short-hand method for each of the type values declared at the top. And then there's 397 # TableDefinition#lock_version that'll add lock_version as integer not nullable with default 0, and 395 398 # TableDefinition#timestamps that'll add created_at and updated_at as datetimes. 396 399 def column(name, type, options = {}) 397 400 column = self[name] || ColumnDefinition.new(@base, name, type) … … 415 418 EOV 416 419 end 417 420 421 # Short-hand method for adding column lock_version as integer not nullable with default 0 422 # This column will then be used to manage optimistic locking. 423 def lock_version 424 column(:lock_version, :integer, {:default => 0, :null => false}) 425 end 426 427 # Short-hand method for adding columns created_at and updated_at as datetimes. 418 428 def timestamps 419 429 column(:created_at, :datetime) 420 430 column(:updated_at, :datetime) -
activerecord/test/fixtures/db_definitions/db2.drop.sql
old new 14 14 DROP TABLE entrants; 15 15 DROP TABLE colnametests; 16 16 DROP TABLE mixins; 17 DROP TABLE people;18 17 DROP TABLE readers; 19 18 DROP TABLE binaries; 20 19 DROP TABLE computers; -
activerecord/test/fixtures/db_definitions/db2.sql
old new 129 129 PRIMARY KEY (id) 130 130 ); 131 131 132 CREATE TABLE people (133 id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),134 first_name VARCHAR(40) NOT NULL,135 lock_version INT DEFAULT 0,136 PRIMARY KEY (id)137 );138 139 132 CREATE TABLE readers ( 140 133 id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), 141 134 post_id INT NOT NULL, -
activerecord/test/fixtures/db_definitions/firebird.drop.sql
old new 14 14 DROP TABLE entrants; 15 15 DROP TABLE colnametests; 16 16 DROP TABLE mixins; 17 DROP TABLE people;18 17 DROP TABLE readers; 19 18 DROP TABLE binaries; 20 19 DROP TABLE computers; … … 49 48 DROP GENERATOR entrants_seq; 50 49 DROP GENERATOR colnametests_seq; 51 50 DROP GENERATOR mixins_seq; 52 DROP GENERATOR people_seq;53 51 DROP GENERATOR binaries_seq; 54 52 DROP GENERATOR computers_seq; 55 53 DROP GENERATOR posts_seq; -
activerecord/test/fixtures/db_definitions/firebird.sql
old new 160 160 CREATE GENERATOR mixins_seq; 161 161 SET GENERATOR mixins_seq TO 10000; 162 162 163 CREATE TABLE people (164 id BIGINT NOT NULL,165 first_name VARCHAR(40),166 lock_version INTEGER DEFAULT 0 NOT NULL,167 PRIMARY KEY (id)168 );169 CREATE GENERATOR people_seq;170 SET GENERATOR people_seq TO 10000;171 172 163 CREATE TABLE readers ( 173 164 id BIGINT NOT NULL, 174 165 post_id BIGINT NOT NULL, -
activerecord/test/fixtures/db_definitions/frontbase.drop.sql
old new 14 14 DROP TABLE entrants CASCADE; 15 15 DROP TABLE colnametests CASCADE; 16 16 DROP TABLE mixins CASCADE; 17 DROP TABLE people CASCADE;18 17 DROP TABLE readers CASCADE; 19 18 DROP TABLE binaries CASCADE; 20 19 DROP TABLE computers CASCADE; -
activerecord/test/fixtures/db_definitions/frontbase.sql
old new 145 145 ); 146 146 SET UNIQUE FOR mixins(id); 147 147 148 CREATE TABLE people (149 id integer DEFAULT unique,150 first_name varchar(65536),151 lock_version integer default 0,152 PRIMARY KEY (id)153 );154 SET UNIQUE FOR people(id);155 156 148 CREATE TABLE readers ( 157 149 id integer DEFAULT unique, 158 150 post_id INTEGER NOT NULL, -
activerecord/test/fixtures/db_definitions/mysql.drop.sql
old new 14 14 DROP TABLE entrants; 15 15 DROP TABLE colnametests; 16 16 DROP TABLE mixins; 17 DROP TABLE people;18 17 DROP TABLE readers; 19 18 DROP TABLE binaries; 20 19 DROP TABLE computers; -
activerecord/test/fixtures/db_definitions/mysql.sql
old new 130 130 PRIMARY KEY (`id`) 131 131 ) TYPE=InnoDB; 132 132 133 CREATE TABLE `people` (134 `id` INTEGER NOT NULL auto_increment PRIMARY KEY,135 `first_name` VARCHAR(40) NOT NULL,136 `lock_version` INTEGER NOT NULL DEFAULT 0137 ) TYPE=InnoDB;138 139 133 CREATE TABLE `readers` ( 140 134 `id` int(11) NOT NULL auto_increment PRIMARY KEY, 141 135 `post_id` INTEGER NOT NULL, -
activerecord/test/fixtures/db_definitions/openbase.sql
old new 180 180 CREATE PRIMARY KEY mixins (id) 181 181 go 182 182 183 CREATE TABLE people (184 id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,185 first_name text,186 lock_version integer default 0187 )188 go189 CREATE PRIMARY KEY people (id)190 go191 192 183 CREATE TABLE readers ( 193 184 id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, 194 185 post_id integer NOT NULL, -
activerecord/test/fixtures/db_definitions/oracle.drop.sql
old new 16 16 drop table entrants; 17 17 drop table colnametests; 18 18 drop table mixins; 19 drop table people;20 19 drop table readers; 21 20 drop table binaries; 22 21 drop table comments; … … 49 48 drop sequence entrants_seq; 50 49 drop sequence colnametests_seq; 51 50 drop sequence mixins_seq; 52 drop sequence people_seq;53 51 drop sequence binaries_seq; 54 52 drop sequence posts_seq; 55 53 drop sequence comments_seq; -
activerecord/test/fixtures/db_definitions/oracle.sql
old new 202 202 ); 203 203 create sequence mixins_seq minvalue 10000; 204 204 205 create table people (206 id integer not null,207 first_name varchar(40) null,208 lock_version integer default 0,209 primary key (id)210 );211 create sequence people_seq minvalue 10000;212 213 205 create table readers ( 214 206 id integer not null, 215 207 post_id integer not null, -
activerecord/test/fixtures/db_definitions/postgresql.drop.sql
old new 16 16 DROP TABLE entrants; 17 17 DROP TABLE colnametests; 18 18 DROP TABLE mixins; 19 DROP TABLE people;20 19 DROP TABLE readers; 21 20 DROP TABLE binaries; 22 21 DROP TABLE computers; -
activerecord/test/fixtures/db_definitions/postgresql.sql
old new 141 141 updated_at timestamp 142 142 ); 143 143 144 CREATE TABLE people (145 id serial primary key,146 first_name text,147 lock_version integer default 0148 );149 150 144 CREATE TABLE readers ( 151 145 id serial primary key, 152 146 post_id integer NOT NULL, -
activerecord/test/fixtures/db_definitions/schema.rb
old new 9 9 ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000" 10 10 end 11 11 end 12 13 create_table :people, :force => true do |t| 14 t.string :first_name 15 t.lock_version 16 end 12 17 13 18 create_table :taggings, :force => true do |t| 14 19 t.column :tag_id, :integer -
activerecord/test/fixtures/db_definitions/sqlite.drop.sql
old new 14 14 DROP TABLE entrants; 15 15 DROP TABLE colnametests; 16 16 DROP TABLE mixins; 17 DROP TABLE people;18 17 DROP TABLE readers; 19 18 DROP TABLE binaries; 20 19 DROP TABLE computers; -
activerecord/test/fixtures/db_definitions/sqlite.sql
old new 117 117 'updated_at' DATETIME DEFAULT NULL 118 118 ); 119 119 120 CREATE TABLE 'people' (121 'id' INTEGER NOT NULL PRIMARY KEY,122 'first_name' VARCHAR(40) DEFAULT NULL,123 'lock_version' INTEGER NOT NULL DEFAULT 0124 );125 126 120 CREATE TABLE 'readers' ( 127 121 'id' INTEGER NOT NULL PRIMARY KEY, 128 122 'post_id' INTEGER NOT NULL, -
activerecord/test/fixtures/db_definitions/sybase.drop.sql
old new 14 14 DROP TABLE entrants 15 15 DROP TABLE colnametests 16 16 DROP TABLE mixins 17 DROP TABLE people18 17 DROP TABLE readers 19 18 DROP TABLE binaries 20 19 DROP TABLE computers -
activerecord/test/fixtures/db_definitions/sybase.sql
old new 116 116 type varchar(40) NULL 117 117 ) 118 118 119 CREATE TABLE people (120 id numeric(9,0) IDENTITY PRIMARY KEY,121 first_name varchar(40) NULL,122 lock_version int DEFAULT 0123 )124 125 119 CREATE TABLE readers ( 126 120 id numeric(9,0) IDENTITY PRIMARY KEY, 127 121 post_id int NOT NULL,