module Timetrap class Entry < Sequel::Model plugin :schema def start= time self[:start]= Chronic.parse(time) || time end def end= time self[:end]= Chronic.parse(time) || time end def self.sheets map{|e|e.sheet}.uniq.sort end # do a quick pseudo migration. This should only get executed on the first run set_schema do primary_key :id column :note, :string column :start, :timestamp column :end, :timestamp column :sheet, :string end create_table unless table_exists? end class Meta < Sequel::Model(:meta) plugin :schema set_schema do primary_key :id column :key, :string column :value, :string end create_table unless table_exists? end end