Skip to content

Commit 299fe14

Browse files
committed
Migrations
1 parent f56f465 commit 299fe14

File tree

2 files changed

+71
-5
lines changed

2 files changed

+71
-5
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Sequel.migration do
2+
change do
3+
4+
create_table(:configurations) do
5+
primary_key :id, :type=>"int(11) unsigned"
6+
column :name, "varchar(50)", :default=>"", :null=>false
7+
column :audit_frequency, "int(11) unsigned", :default=>1440, :null=>false
8+
column :github_token, "char(40)", :default=>"", :null=>false
9+
10+
index [:name], :name=>:name, :unique=>true
11+
end
12+
13+
create_table(:notifications) do
14+
primary_key :id, :type=>"int(11) unsigned"
15+
column :name, "varchar(50)", :default=>"", :null=>false
16+
column :notification_type_id, "tinyint(3)", :default=>0, :null=>false
17+
column :target, "varchar(200)", :default=>"", :null=>false
18+
end
19+
20+
create_table :projects do
21+
primary_key :id, :type=>"int(11) unsigned"
22+
column :name, "varchar(200)", :default=>"", :null=>false
23+
column :rule_sets, "varchar(200)", :default=>"", :null=>false
24+
column :next_audit, "int(11) unsigned", :default=>0, :null=>false
25+
column :last_commit_time, "datetime"
26+
column :date_created, "timestamp", :default=>Sequel::CURRENT_TIMESTAMP, :null=>false
27+
28+
index [:name], :name=>:name, :unique=>true
29+
end
30+
31+
create_table(:rule_sets) do
32+
primary_key :id, :type=>"int(11) unsigned"
33+
column :name, "varchar(50)", :default=>"", :null=>false
34+
column :rules, "longtext", :null=>false
35+
column :description, "text"
36+
37+
index [:name], :name=>:name, :unique=>true
38+
end
39+
40+
create_table(:commits) do
41+
primary_key :id, :type=>"int(11) unsigned"
42+
foreign_key :project_id, :projects, :type=>"int(11) unsigned", :null=>false, :key=>[:id]
43+
column :status_type_id, "tinyint(3) unsigned", :default=>0, :null=>false
44+
column :commit_date, "datetime", :null=>false
45+
column :commit_hash, "char(40)", :null=>false
46+
column :audit_results, "longtext", :null=>false
47+
column :date_created, "timestamp", :default=>Sequel::CURRENT_TIMESTAMP, :null=>false
48+
49+
index [:project_id], :name=>:project_id
50+
index [:commit_hash], :name=>:uq_commit_hash, :unique=>true
51+
end
52+
53+
create_table(:rules) do
54+
primary_key :id, :type=>"int(11) unsigned"
55+
column :name, "varchar(50)", :default=>"", :null=>false
56+
column :rule_type_id, "int(11) unsigned", :null=>false
57+
column :value, "longtext", :null=>false
58+
column :description, "text"
59+
foreign_key :notification_id, :notifications, :type=>"int(11) unsigned", :key=>[:id]
60+
61+
index [:name], :name=>:name, :unique=>true
62+
index [:notification_id], :name=>:notification_id
63+
end
64+
end
65+
end

db/schema.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@
7070
end
7171
end
7272
end
73-
Sequel.migration do
74-
change do
75-
self << "INSERT INTO `schema_migrations` (`filename`) VALUES ('20170119020524_add_credentials_to_projects.rb')"
76-
end
77-
end
73+
Sequel.migration do
74+
change do
75+
self << "INSERT INTO `schema_migrations` (`filename`) VALUES ('20170118000000_initial_migration.rb')"
76+
self << "INSERT INTO `schema_migrations` (`filename`) VALUES ('20170119020524_add_credentials_to_projects.rb')"
77+
end
78+
end

0 commit comments

Comments
 (0)