Skip to content

A platform for community discussion. Free, open, simple.

DEV: Automatically annotate plugin models alongside core models

David Taylor5605dba85cc1
diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake
index 2fca50edfb9..dd7d4992cae 100644
--- a/lib/tasks/auto_annotate_models.rake
+++ b/lib/tasks/auto_annotate_models.rake
@@ -15,7 +15,7 @@ if (Rails.env.development? || Rails.env.test?)
'position_in_factory' => "before",
'show_indexes' => "true",
'simple_indexes' => "false",
- 'model_dir' => "app/models",
+ 'model_dir' => ["app/models"] + Dir.glob("plugins/**/app/models"),
'include_version' => "false",
'require' => "",
'exclude_tests' => "true",
diff --git a/plugins/poll/app/models/poll.rb b/plugins/poll/app/models/poll.rb
index 4328b1f3f21..e8ae6942e1b 100644
--- a/plugins/poll/app/models/poll.rb
+++ b/plugins/poll/app/models/poll.rb
@@ -56,8 +56,8 @@ end
#
# Table name: polls
#
-# id :bigint(8) not null, primary key
-# post_id :bigint(8)
+# id :bigint not null, primary key
+# post_id :bigint
# name :string default("poll"), not null
# close_at :datetime
# type :integer default("regular"), not null
@@ -76,3 +76,7 @@ end
# index_polls_on_post_id (post_id)
# index_polls_on_post_id_and_name (post_id,name) UNIQUE
#
+# Foreign Keys
+#
+# fk_rails_... (post_id => posts.id)
+#
diff --git a/plugins/poll/app/models/poll_option.rb b/plugins/poll/app/models/poll_option.rb
index 66c39621590..7eea2dd0c9d 100644
--- a/plugins/poll/app/models/poll_option.rb
+++ b/plugins/poll/app/models/poll_option.rb
@@ -9,8 +9,8 @@ end
#
# Table name: poll_options
#
-# id :bigint(8) not null, primary key
-# poll_id :bigint(8)
+# id :bigint not null, primary key
+# poll_id :bigint
# digest :string not null
# html :text not null
# anonymous_votes :integer
@@ -22,3 +22,7 @@ end
# index_poll_options_on_poll_id (poll_id)
# index_poll_options_on_poll_id_and_digest (poll_id,digest) UNIQUE
#
+# Foreign Keys
+#
+# fk_rails_... (poll_id => polls.id)
+#
diff --git a/plugins/poll/app/models/poll_vote.rb b/plugins/poll/app/models/poll_vote.rb
index 409063c2e5b..6f453dacb8d 100644
--- a/plugins/poll/app/models/poll_vote.rb
+++ b/plugins/poll/app/models/poll_vote.rb
@@ -10,9 +10,9 @@ end
#
# Table name: poll_votes
#
-# poll_id :bigint(8)
-# poll_option_id :bigint(8)
-# user_id :bigint(8)
+# poll_id :bigint
+# poll_option_id :bigint
+# user_id :bigint
# created_at :datetime not null
# updated_at :datetime not null
#
@@ -23,3 +23,9 @@ end
# index_poll_votes_on_poll_option_id (poll_option_id)
# index_poll_votes_on_user_id (user_id)
#
+# Foreign Keys
+#
+# fk_rails_... (poll_id => polls.id)
+# fk_rails_... (poll_option_id => poll_options.id)
+# fk_rails_... (user_id => users.id)
+#