1 class InitialSchema < ActiveRecord::Migration
3 create_table 'folders', :force => true do |t|
4 t.column 'name', :string
5 t.column 'date_modified', :datetime
6 t.column 'user_id', :integer, :default => 0
7 t.column 'parent_id', :integer, :default => 0
8 t.column 'root_id', :integer
9 t.column 'is_root', :boolean, :default => false
10 t.column 'lft', :integer, :default => nil
11 t.column 'rgt', :integer, :default => nil
12 t.column 'depth', :integer, :default => 0
13 t.column 'quota', :integer, :default => 0
14 t.column 'size', :integer, :default => 0
15 t.column 'no_of_files', :integer, :default => 0
16 t.column 'note', :text
17 t.column 'note_inheritable', :boolean, :default => false
18 t.column 'note_upload', :text
19 t.column 'note_upload_inheritable', :boolean, :default => false
21 add_index :folders, :name
22 add_index :folders, :date_modified
23 add_index :folders, :user_id
24 add_index :folders, :parent_id
25 add_index :folders, :is_root
26 add_index :folders, :lft
27 add_index :folders, :rgt
28 add_index :folders, :quota
29 add_index :folders, :size
30 add_index :folders, :root_id
31 add_index :folders, :depth
32 add_index :folders, :no_of_files
33 add_index :folders, :note
34 add_index :folders, :note_inheritable
35 add_index :folders, :note_upload
36 add_index :folders, :note_upload_inheritable
38 create_table 'group_permissions', :force => true do |t|
39 t.column 'folder_id', :integer, :default => 0
40 t.column 'group_id', :integer, :default => 0
41 t.column 'can_create', :boolean, :default => false
42 t.column 'can_read', :boolean, :default => false
43 t.column 'can_update', :boolean, :default => false
44 t.column 'can_delete', :boolean, :default => false
46 add_index :group_permissions, :folder_id
47 add_index :group_permissions, :group_id
48 add_index :group_permissions, :can_create
49 add_index :group_permissions, :can_read
50 add_index :group_permissions, :can_update
51 add_index :group_permissions, :can_delete
53 create_table 'groups', :force => true do |t|
54 t.column 'name', :string
55 t.column 'is_the_administrators_group', :boolean, :default => false
57 add_index :groups, :name
58 add_index :groups, :is_the_administrators_group
60 create_table 'groups_users', :id => false, :force => true do |t|
61 t.column 'group_id', :integer, :default=>0
62 t.column 'user_id', :integer, :default=>0
64 add_index :groups_users, [:group_id, :user_id]
66 create_table 'myfiles', :force => true do |t|
67 t.column 'filename', :string
68 t.column 'filesize', :integer
69 t.column 'date_modified', :datetime
70 t.column 'folder_id', :integer, :default => 0
71 t.column 'user_id', :integer, :default => 0
72 t.column 'indexed', :boolean, :default => false
74 add_index :myfiles, :filename
75 add_index :myfiles, :filesize
76 add_index :myfiles, :date_modified
77 add_index :myfiles, :folder_id
78 add_index :myfiles, :user_id
79 add_index :myfiles, :indexed
82 create_table 'usages', :force => true do |t|
83 t.column 'download_date_time', :datetime
84 t.column 'comment', :string
85 t.column 'action', :string
86 t.column 'filename', :string
87 t.column 'myfile_id', :integer, :default => 0
88 t.column 'folder_id', :integer, :default => 0
89 t.column 'user_id', :integer, :default => 0
91 add_index :usages, :download_date_time
92 add_index :usages, :myfile_id
93 add_index :usages, :user_id
94 add_index :usages, :comment
95 add_index :usages, :action
96 add_index :usages, :filename
97 add_index :usages, :folder_id
99 create_table 'clipboards', :force => true do |t|
100 t.column 'user_id', :integer, :default => 0
101 t.column 'myfile_id', :integer, :default => 0
102 t.column 'folder_id', :integer, :default => 0
104 add_index :clipboards, :user_id
105 add_index :clipboards, :myfile_id
106 add_index :clipboards, :folder_id
108 create_table 'users', :force => true do |t|
109 t.column 'name', :string
110 t.column 'email', :string
111 t.column 'hashed_password', :string
112 t.column 'is_the_administrator', :boolean, :default => false
113 t.column 'rss_access_key', :string
114 t.column 'password_salt', :string
116 add_index :users, :name
117 add_index :users, :email
118 add_index :users, :hashed_password
119 add_index :users, :is_the_administrator
120 add_index :users, :rss_access_key
121 add_index :users, :password_salt
124 create_table 'news', :force => true do |t|
125 t.column 'title', :string
126 t.column 'date', :datetime
127 t.column 'text', :text
129 add_index :news, :title
130 add_index :news, :date
131 add_index :news, :text
136 drop_table 'group_folders'
138 drop_table 'groups_users'