ANN: Sequel 0.1.9.3 Released

S

Sharon Rosner

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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Sequel now includes migration functionality, thanks to Florian A=DFmann.
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 =3D> 32, :unique =3D> 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D

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

DB.create_table :items
varchar :name, :size =3D> 32
...
end

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

Miscellanea
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

* Improved robustness of MySQL::Dataset#field_name.

* Added Sequel.single_threaded=3D convenience method.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D

Sequel project page:
<http://code.google.com/p/ruby-sequel>

Sequel documentation:
<http://sequel.rubyforge.org>

Join the Sequel-talk group:
<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 sequel
cd sequel
rake install
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top