lib/integrity/migrations.rb in alphasights-integrity-0.1.9.8 vs lib/integrity/migrations.rb in alphasights-integrity-0.1.10
- old
+ new
@@ -37,13 +37,13 @@
up do
create_table :integrity_projects do
column :id, Integer, :serial => true
column :name, String, :nullable => false
column :permalink, String
- column :uri, Text, :nullable => false
+ column :uri, URI, :nullable => false
column :branch, String, :nullable => false, :default => "master"
- column :command, Text, :nullable => false, :default => "rake"
+ column :command, String, :nullable => false, :default => "rake"
column :public, Boolean, :default => true
column :building, Boolean, :default => false
column :created_at, DateTime
column :updated_at, DateTime
@@ -81,16 +81,16 @@
property :project_id, Integer
end
create_table :integrity_commits do
column :id, Integer, :serial => true
- column :identifier, String, :size => 40, :nullable => false
- column :message, Text, :nullable => true
- column :author, String, :nullable => true, :length => 255
+ column :identifier, String, :nullable => false
+ column :message, String, :nullable => false, :length => 255
+ column :author, String, :nullable => false, :length => 255
column :committed_at, DateTime, :nullable => false
- column :created_at, DateTime
- column :updated_at, DateTime
+ column :created_at, DateTime
+ column :updated_at, DateTime
column :project_id, Integer
end
modify_table :integrity_builds do
@@ -122,11 +122,10 @@
if commit.nil?
commit = Commit.create(:identifier => build.commit_identifier,
:message => build.commit_metadata[:message],
:author => build.commit_metadata[:author],
- :url => build.commit_metadata[:url],
:committed_at => build.commit_metadata[:date],
:project_id => build.project_id)
end
Build.create(:commit_id => commit.id,
@@ -147,16 +146,47 @@
# TODO: sqlite doesn't support DROP COLUMN ...
# modify_table(:integrity_notifiers) { drop_column :enabled }
end
end
- migration 4, :add_url_to_commits do
+ migration 4, :add_commit_uri_column do
+ up do
+ modify_table(:integrity_commits) { add_column :uri, URI }
+ end
+
+ down do
+ #modify_table(:integrity_commits) { add_column :changeset, String }
+ end
+ end
+ end
+
+ migration 5, :nil_commit_metadata do
up do
- modify_table(:integrity_commits) { add_column :url, Text }
+ all_commits = Commit.all.collect { |c| c.dup }
+ drop_table :integrity_commits
+
+ create_table :integrity_commits do
+ column :id, Integer, :serial => true
+ column :identifier, String, :nullable => false
+ column :message, String, :nullable => true, :length => 255
+ column :author, String, :nullable => true, :length => 255
+ column :committed_at, DateTime, :nullable => false
+ column :created_at, DateTime
+ column :updated_at, DateTime
+
+ column :project_id, Integer
+ end
+
+ all_commits.each { |commit| Commit.create(commit.attributes) }
end
+ end
- down do
- #modify_table(:integrity_commits) { drop_column :url }
+=begin
+TODO: drop the :building column of the project table
+
+ migration 5, :remove_building_column do
+ up do
+ modify_table(:integrity_projects) { drop_column :building }
end
end
- end
+=end
end