Sha256: 3b7b422a6fd9986034f240ce055518495f615124ec462ee37e3a2d9c09ef7fed
Contents?: true
Size: 1.33 KB
Versions: 25
Compression:
Stored size: 1.33 KB
Contents
require 'sequel' # check database version CREATE_TABLE_SCRIPT = File.expand_path("../../../db/create.sql", __FILE__) print "Checking vmail.db version... " db = Sequel.connect 'sqlite://vmail.db' if db.tables.include?(:version) && (r = db[:version].first) && r[:vmail_version] != Vmail::VERSION print "Vmail database version is outdated. Recreating.\n" `rm vmail.db` `sqlite3 vmail.db < #{CREATE_TABLE_SCRIPT}` else print "OK\n" end db.disconnect if !File.size?('vmail.db') puts `sqlite3 vmail.db < #{CREATE_TABLE_SCRIPT}` end DB = Sequel.connect 'sqlite://vmail.db' puts "Connecting to database" if DB[:version].count == 0 DB[:version].insert(:vmail_version => Vmail::VERSION) end module Vmail class Message < Sequel::Model(:messages) set_primary_key :message_id one_to_many :labelings many_to_many :labels, :join_table => 'labelings' end end if DB[:version].count == 0 DB[:version].insert(:vmail_version => Vmail::VERSION) end module Vmail class Message < Sequel::Model(:messages) set_primary_key :message_id one_to_many :labelings many_to_many :labels, :join_table => 'labelings' end class Label < Sequel::Model(:labels) set_primary_key :label_id one_to_many :labelings many_to_many :messages, :join_table => 'labelings' end class Labeling < Sequel::Model(:labelings) end end
Version data entries
25 entries across 25 versions & 1 rubygems