summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/01_admin.rb1
-rw-r--r--db/fixtures/development/02_source_code.rb29
-rw-r--r--db/fixtures/development/03_group.rb5
-rw-r--r--db/fixtures/development/04_project.rb61
-rw-r--r--db/fixtures/development/05_users.rb2
-rw-r--r--db/fixtures/development/06_teams.rb23
-rw-r--r--db/migrate/20130617095603_create_users_groups.rb11
-rw-r--r--db/migrate/20130621195223_add_notification_level_to_user_group.rb5
-rw-r--r--db/migrate/20130622115340_add_more_db_index.rb12
-rw-r--r--db/migrate/20130624162710_add_fingerprint_to_key.rb6
-rw-r--r--db/schema.rb93
11 files changed, 151 insertions, 97 deletions
diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb
index fbe41e4d22d..948a3459283 100644
--- a/db/fixtures/development/01_admin.rb
+++ b/db/fixtures/development/01_admin.rb
@@ -7,5 +7,6 @@ User.seed(:id, [
password: "5iveL!fe",
password_confirmation: "5iveL!fe",
admin: true,
+ projects_limit: 100,
}
])
diff --git a/db/fixtures/development/02_source_code.rb b/db/fixtures/development/02_source_code.rb
deleted file mode 100644
index 5ce5bcf4aba..00000000000
--- a/db/fixtures/development/02_source_code.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-gitlab_shell_path = File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
-root = Gitlab.config.gitlab_shell.repos_path
-
-projects = [
- { path: 'underscore.git', git: 'https://github.com/documentcloud/underscore.git' },
- { path: 'diaspora.git', git: 'https://github.com/diaspora/diaspora.git' },
- { path: 'brightbox/brightbox-cli.git', git: 'https://github.com/brightbox/brightbox-cli.git' },
- { path: 'brightbox/puppet.git', git: 'https://github.com/brightbox/puppet.git' },
- { path: 'gitlab/gitlabhq.git', git: 'https://github.com/gitlabhq/gitlabhq.git' },
- { path: 'gitlab/gitlab-ci.git', git: 'https://github.com/gitlabhq/gitlab-ci.git' },
- { path: 'gitlab/gitlab-recipes.git', git: 'https://github.com/gitlabhq/gitlab-recipes.git' },
-]
-
-projects.each do |project|
- project_path = File.join(root, project[:path])
-
- if File.exists?(project_path)
- print '-'
- next
- end
- if system("#{gitlab_shell_path}/gitlab-shell/bin/gitlab-projects import-project #{project[:path]} #{project[:git]}")
- print '.'
- else
- print 'F'
- end
-end
-
-puts "OK".green
-
diff --git a/db/fixtures/development/03_group.rb b/db/fixtures/development/03_group.rb
deleted file mode 100644
index 01174a4b72a..00000000000
--- a/db/fixtures/development/03_group.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-Group.seed(:id, [
- { id: 99, name: "GitLab", path: 'gitlab', owner_id: 1 },
- { id: 100, name: "Brightbox", path: 'brightbox', owner_id: 1 },
- { id: 101, name: "KDE", path: 'kde', owner_id: 1 },
-])
diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb
index 9904c48e518..43178dee25d 100644
--- a/db/fixtures/development/04_project.rb
+++ b/db/fixtures/development/04_project.rb
@@ -1,20 +1,49 @@
-Project.seed(:id, [
+project_urls = [
+ 'https://github.com/documentcloud/underscore.git',
+ 'https://github.com/diaspora/diaspora.git',
+ 'https://github.com/diaspora/diaspora-project-site.git',
+ 'https://github.com/diaspora/diaspora-client.git',
+ 'https://github.com/brightbox/brightbox-cli.git',
+ 'https://github.com/brightbox/puppet.git',
+ 'https://github.com/gitlabhq/gitlabhq.git',
+ 'https://github.com/gitlabhq/gitlab-ci.git',
+ 'https://github.com/gitlabhq/gitlab-recipes.git',
+ 'https://github.com/gitlabhq/gitlab-shell.git',
+ 'https://github.com/gitlabhq/grack.git',
+ 'https://github.com/twitter/flight.git',
+ 'https://github.com/twitter/typeahead.js.git',
+ 'https://github.com/h5bp/html5-boilerplate.git',
+ 'https://github.com/h5bp/mobile-boilerplate.git',
+]
- # Global
- { id: 1, name: "Underscore.js", path: "underscore", creator_id: 1 },
- { id: 2, name: "Diaspora", path: "diaspora", creator_id: 1 },
+project_urls.each_with_index do |url, i|
+ group_path, project_path = url.split('/')[-2..-1]
- # Brightbox
- { id: 3, namespace_id: 100, name: "Brightbox CLI", path: "brightbox-cli", creator_id: 1 },
- { id: 4, namespace_id: 100, name: "Puppet", path: "puppet", creator_id: 1 },
+ group = Group.find_by_path(group_path)
- # KDE
- { id: 5, namespace_id: 101, name: "kdebase", path: "kdebase", creator_id: 1},
- { id: 6, namespace_id: 101, name: "kdelibs", path: "kdelibs", creator_id: 1},
- { id: 7, namespace_id: 101, name: "amarok", path: "amarok", creator_id: 1},
+ unless group
+ group = Group.new(
+ name: group_path.titleize,
+ path: group_path
+ )
+ group.owner = User.first
+ group.save
+ end
- # GitLab
- { id: 8, namespace_id: 99, name: "gitlabhq", path: "gitlabhq", creator_id: 1},
- { id: 9, namespace_id: 99, name: "gitlab-ci", path: "gitlab-ci", creator_id: 1},
- { id: 10, namespace_id: 99, name: "gitlab-recipes", path: "gitlab-recipes", creator_id: 1},
-])
+ project_path.gsub!(".git", "")
+
+ params = {
+ import_url: url,
+ namespace_id: group.id,
+ name: project_path.titleize
+ }
+
+ project = Projects::CreateContext.new(User.first, params).execute
+
+ if project.valid?
+ print '.'
+ else
+ puts project.errors.full_messages
+ print 'F'
+ end
+end
diff --git a/db/fixtures/development/05_users.rb b/db/fixtures/development/05_users.rb
index abcb0259618..cbb3e636acc 100644
--- a/db/fixtures/development/05_users.rb
+++ b/db/fixtures/development/05_users.rb
@@ -1,5 +1,5 @@
Gitlab::Seeder.quiet do
- (2..300).each do |i|
+ (2..50).each do |i|
begin
User.seed(:id, [{
id: i,
diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb
index f82977d7fdc..a1e01879db5 100644
--- a/db/fixtures/development/06_teams.rb
+++ b/db/fixtures/development/06_teams.rb
@@ -1,14 +1,23 @@
ActiveRecord::Base.observers.disable :all
Gitlab::Seeder.quiet do
- Project.all.each do |project|
- project.team << [User.first, :master]
- print '.'
+ Group.all.each do |group|
+ User.all.sample(4).each do |user|
+ if group.add_users([user.id], UsersGroup.group_access_roles.values.sample)
+ print '.'
+ else
+ print 'F'
+ end
+ end
+ end
- User.all.sample(rand(10)).each do |user|
- role = [:master, :developer, :reporter].sample
- project.team << [user, role]
- print '.'
+ Project.all.each do |project|
+ User.all.sample(4).each do |user|
+ if project.team << [user, UsersProject.access_roles.values.sample]
+ print '.'
+ else
+ print 'F'
+ end
end
end
end
diff --git a/db/migrate/20130617095603_create_users_groups.rb b/db/migrate/20130617095603_create_users_groups.rb
new file mode 100644
index 00000000000..2efc04f1151
--- /dev/null
+++ b/db/migrate/20130617095603_create_users_groups.rb
@@ -0,0 +1,11 @@
+class CreateUsersGroups < ActiveRecord::Migration
+ def change
+ create_table :users_groups do |t|
+ t.integer :group_access, null: false
+ t.integer :group_id, null: false
+ t.integer :user_id, null: false
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20130621195223_add_notification_level_to_user_group.rb b/db/migrate/20130621195223_add_notification_level_to_user_group.rb
new file mode 100644
index 00000000000..8c2e3dfcaca
--- /dev/null
+++ b/db/migrate/20130621195223_add_notification_level_to_user_group.rb
@@ -0,0 +1,5 @@
+class AddNotificationLevelToUserGroup < ActiveRecord::Migration
+ def change
+ add_column :users_groups, :notification_level, :integer, null: false, default: 3
+ end
+end
diff --git a/db/migrate/20130622115340_add_more_db_index.rb b/db/migrate/20130622115340_add_more_db_index.rb
new file mode 100644
index 00000000000..9570a7a3f1e
--- /dev/null
+++ b/db/migrate/20130622115340_add_more_db_index.rb
@@ -0,0 +1,12 @@
+class AddMoreDbIndex < ActiveRecord::Migration
+ def change
+ add_index :deploy_keys_projects, :project_id
+ add_index :web_hooks, :project_id
+ add_index :protected_branches, :project_id
+
+ add_index :users_groups, :user_id
+ add_index :snippets, :author_id
+ add_index :notes, :author_id
+ add_index :notes, [:noteable_id, :noteable_type]
+ end
+end
diff --git a/db/migrate/20130624162710_add_fingerprint_to_key.rb b/db/migrate/20130624162710_add_fingerprint_to_key.rb
new file mode 100644
index 00000000000..544a8366727
--- /dev/null
+++ b/db/migrate/20130624162710_add_fingerprint_to_key.rb
@@ -0,0 +1,6 @@
+class AddFingerprintToKey < ActiveRecord::Migration
+ def change
+ add_column :keys, :fingerprint, :string
+ remove_column :keys, :identifier
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b755d555630..3208e8c2354 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130326142630) do
+ActiveRecord::Schema.define(:version => 20130624162710) do
create_table "deploy_keys_projects", :force => true do |t|
t.integer "deploy_key_id", :null => false
@@ -20,6 +20,8 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.datetime "updated_at", :null => false
end
+ add_index "deploy_keys_projects", ["project_id"], :name => "index_deploy_keys_projects_on_project_id"
+
create_table "events", :force => true do |t|
t.string "target_type"
t.integer "target_id"
@@ -53,8 +55,8 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.integer "assignee_id"
t.integer "author_id"
t.integer "project_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.integer "position", :default => 0
t.string "branch_name"
t.text "description"
@@ -71,15 +73,14 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
create_table "keys", :force => true do |t|
t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.text "key"
t.string "title"
- t.string "identifier"
t.string "type"
+ t.string "fingerprint"
end
- add_index "keys", ["identifier"], :name => "index_keys_on_identifier"
add_index "keys", ["user_id"], :name => "index_keys_on_user_id"
create_table "merge_requests", :force => true do |t|
@@ -89,8 +90,8 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.integer "author_id"
t.integer "assignee_id"
t.string "title"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.text "st_commits", :limit => 2147483647
t.text "st_diffs", :limit => 2147483647
t.integer "milestone_id"
@@ -139,8 +140,8 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.text "note"
t.string "noteable_type"
t.integer "author_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.integer "project_id"
t.string "attachment"
t.string "line_code"
@@ -148,8 +149,10 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.integer "noteable_id"
end
+ add_index "notes", ["author_id"], :name => "index_notes_on_author_id"
add_index "notes", ["commit_id"], :name => "index_notes_on_commit_id"
add_index "notes", ["created_at"], :name => "index_notes_on_created_at"
+ add_index "notes", ["noteable_id", "noteable_type"], :name => "index_notes_on_noteable_id_and_noteable_type"
add_index "notes", ["noteable_type"], :name => "index_notes_on_noteable_type"
add_index "notes", ["project_id", "noteable_type"], :name => "index_notes_on_project_id_and_noteable_type"
add_index "notes", ["project_id"], :name => "index_notes_on_project_id"
@@ -158,8 +161,8 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.string "name"
t.string "path"
t.text "description"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.integer "creator_id"
t.string "default_branch"
t.boolean "issues_enabled", :default => true, :null => false
@@ -186,6 +189,8 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.datetime "updated_at", :null => false
end
+ add_index "protected_branches", ["project_id"], :name => "index_protected_branches_on_project_id"
+
create_table "services", :force => true do |t|
t.string "type"
t.string "title"
@@ -206,14 +211,15 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.text "content"
t.integer "author_id", :null => false
t.integer "project_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "file_name"
t.datetime "expires_at"
t.boolean "private", :default => true, :null => false
t.string "type"
end
+ add_index "snippets", ["author_id"], :name => "index_snippets_on_author_id"
add_index "snippets", ["created_at"], :name => "index_snippets_on_created_at"
add_index "snippets", ["expires_at"], :name => "index_snippets_on_expires_at"
add_index "snippets", ["project_id"], :name => "index_snippets_on_project_id"
@@ -228,9 +234,6 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
t.datetime "created_at"
end
- add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
- add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
-
create_table "tags", :force => true do |t|
t.string "name"
end
@@ -262,37 +265,37 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
end
create_table "users", :force => true do |t|
- t.string "email", :default => "", :null => false
- t.string "encrypted_password", :default => "", :null => false
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
- t.integer "sign_in_count", :default => 0
+ t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "name"
- t.boolean "admin", :default => false, :null => false
- t.integer "projects_limit", :default => 10
- t.string "skype", :default => "", :null => false
- t.string "linkedin", :default => "", :null => false
- t.string "twitter", :default => "", :null => false
+ t.boolean "admin", :default => false, :null => false
+ t.integer "projects_limit", :default => 10
+ t.string "skype", :default => "", :null => false
+ t.string "linkedin", :default => "", :null => false
+ t.string "twitter", :default => "", :null => false
t.string "authentication_token"
- t.integer "theme_id", :default => 1, :null => false
+ t.integer "theme_id", :default => 1, :null => false
t.string "bio"
- t.integer "failed_attempts", :default => 0
+ t.integer "failed_attempts", :default => 0
t.datetime "locked_at"
t.string "extern_uid"
t.string "provider"
t.string "username"
- t.boolean "can_create_group", :default => true, :null => false
- t.boolean "can_create_team", :default => true, :null => false
+ t.boolean "can_create_group", :default => true, :null => false
+ t.boolean "can_create_team", :default => true, :null => false
t.string "state"
- t.integer "color_scheme_id", :default => 1, :null => false
- t.integer "notification_level", :default => 1, :null => false
+ t.integer "color_scheme_id", :default => 1, :null => false
+ t.integer "notification_level", :default => 1, :null => false
t.datetime "password_expires_at"
t.integer "created_by_id"
end
@@ -300,16 +303,26 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
add_index "users", ["admin"], :name => "index_users_on_admin"
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
- add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true
add_index "users", ["name"], :name => "index_users_on_name"
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
add_index "users", ["username"], :name => "index_users_on_username"
- create_table "users_projects", :force => true do |t|
+ create_table "users_groups", :force => true do |t|
+ t.integer "group_access", :null => false
+ t.integer "group_id", :null => false
t.integer "user_id", :null => false
- t.integer "project_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.integer "notification_level", :default => 3, :null => false
+ end
+
+ add_index "users_groups", ["user_id"], :name => "index_users_groups_on_user_id"
+
+ create_table "users_projects", :force => true do |t|
+ t.integer "user_id", :null => false
+ t.integer "project_id", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.integer "project_access", :default => 0, :null => false
t.integer "notification_level", :default => 3, :null => false
end
@@ -321,10 +334,12 @@ ActiveRecord::Schema.define(:version => 20130326142630) do
create_table "web_hooks", :force => true do |t|
t.string "url"
t.integer "project_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "type", :default => "ProjectHook"
t.integer "service_id"
end
+ add_index "web_hooks", ["project_id"], :name => "index_web_hooks_on_project_id"
+
end