# ANN: Sequel 0.1.9.3 Released

**URL:** <https://www.ruby-forum.com/t/ann-sequel-0-1-9-3-released/111793>\
**Category:** Ruby\
**Created:** [August 10, 2007, 9:43pm UTC](https://www.ruby-forum.com/t/ann-sequel-0-1-9-3-released/111793 "2007-08-10T21:43:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ciconia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@ciconia](https://www.ruby-forum.com/u/ciconia)\
**Post date:** [August 10, 2007, 9:43pm UTC](https://www.ruby-forum.com/t/ann-sequel-0-1-9-3-released/111793/1 "2007-08-10T21:43:28Z")

</div>

Sequel version 0.1.9.3 has just been released. This release adds new  
database migration functionality and support for specifying field  
sizes in schema definitions.

Following is a discussion of the main changes:

# Database migrations

Sequel now includes migration functionality, thanks to Florian Aßmann.  
The migrator works in very similar fashion to ActiveRecord (Rails)  
migrations. Each migration is defined as a descendant of  
Sequel::Migration with #up and #down methods, e.g.:

class CreateSessions \< Sequel::Migration  
def up  
create\_table :sessions do  
primary\_key :id  
varchar :session\_id, :size =\> 32, :unique =\> true  
timestamp :created\_at  
text :data  
end  
end

```
def down
  drop_table :sessions
end

```

end

You can manually apply the migration as follows:

CreateSessions.apply(DB, :up)

There is also a Sequel::Migrator which can apply migrations and keep  
track of the current schema version by storing it in a schema\_info  
table in the database. This is actually how ActiveRecord keeps track  
of migrations, so Sequel and ActiveRecord are compatible in this  
respect.

The migrator can apply migrations by loading migration files stored in  
a specific directory. The migration files should be named using the  
ActiveRecord convention, e.g.:

001\_create\_sessions.rb  
002\_create\_users.rb  
…

To migrate your database to the latest version, you just need to  
supply the database instance and the directory containing the  
migration files, e.g.:

Sequel::Migrator.apply(DB, ‘.’)

You can also undo all migrations as follows:

Sequel::Migrator.apply(DB, ‘.’, 0) # the database is taken back to  
version 0.

Or specify a specific version:

Sequel::Migrator.apply(DB, ‘.’, 5) # we’re now in version 5.

Note: It is advisable not to use the migrator on production data. This  
code is largely untested (though it conforms to the spec.)

# Support for specifying field sizes in schema definitions

This is another patch from Florian Aßmann. You can now specify field  
sizes when defining schemas, e.g.:

DB.create\_table :items  
varchar :name, :size =\> 32  
…  
end

Note that if a varchar field is specified without a size, the size is  
presumed to be 255.

# Miscellanea

- Improved robustness of MySQL::Dataset#field\_name.

- Added Sequel.single\_threaded= convenience method.

================================

Sequel project page:  
[http://code.google.com/p/ruby-sequel](http://code.google.com/p/ruby-sequel)

Sequel documentation:  
[http://sequel.rubyforge.org](http://sequel.rubyforge.org)

Join the Sequel-talk group:  
[http://groups.google.com/group/sequel-talk](http://groups.google.com/group/sequel-talk)

Install the gem:  
sudo gem install sequel

Or check out the source and install manually:  
svn co [http://ruby-sequel.googlecode.com/svn/trunk](http://ruby-sequel.googlecode.com/svn/trunk) sequel  
cd sequel  
rake install
