This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store mailbox and message state information in a local database to sp…
…eed up future syncs
- Loading branch information
Showing
9 changed files
with
412 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Larch; module Database | ||
|
||
class Account < Sequel::Model | ||
plugin :hook_class_methods | ||
one_to_many :mailboxes, :class => Larch::Database::Mailbox | ||
|
||
before_destroy do | ||
Mailbox.filter(:account_id => id).destroy | ||
end | ||
end | ||
|
||
end; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Larch; module Database | ||
|
||
class Mailbox < Sequel::Model | ||
plugin :hook_class_methods | ||
one_to_many :messages, :class => Larch::Database::Message | ||
|
||
before_destroy do | ||
Message.filter(:mailbox_id => id).destroy | ||
end | ||
end | ||
|
||
end; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Larch; module Database | ||
|
||
class Message < Sequel::Model | ||
end | ||
|
||
end; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class CreateSchema < Sequel::Migration | ||
def down | ||
drop_table :accounts, :mailboxes, :messages | ||
end | ||
|
||
def up | ||
create_table :accounts do | ||
primary_key :id | ||
text :hostname, :null => false | ||
text :username, :null => false | ||
|
||
unique [:hostname, :username] | ||
end | ||
|
||
create_table :mailboxes do | ||
primary_key :id | ||
foreign_key :account_id, :table => :accounts | ||
text :name, :null => false | ||
text :delim, :null => false | ||
text :attr, :null => false, :default => '' | ||
integer :subscribed, :null => false, :default => 0 | ||
integer :uidvalidity | ||
integer :uidnext | ||
|
||
unique [:account_id, :name, :uidvalidity] | ||
end | ||
|
||
create_table :messages do | ||
primary_key :id | ||
foreign_key :mailbox_id, :table => :mailboxes | ||
integer :uid, :null => false | ||
text :guid, :null => false | ||
text :message_id | ||
integer :rfc822_size, :null => false | ||
integer :internaldate, :null => false | ||
text :flags, :null => false, :default => '' | ||
|
||
index :guid | ||
unique [:mailbox_id, :uid] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.