Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e29ccece
Commit
e29ccece
authored
Nov 22, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace model added. Migration to convert exit project/groups
parent
ced242a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
31 deletions
+60
-31
app/models/group.rb
app/models/group.rb
+1
-20
app/models/namespace.rb
app/models/namespace.rb
+20
-0
app/models/project.rb
app/models/project.rb
+10
-1
db/migrate/20121122145155_convert_group_to_namespace.rb
db/migrate/20121122145155_convert_group_to_namespace.rb
+13
-0
db/migrate/20121122150932_add_namespace_id_to_project.rb
db/migrate/20121122150932_add_namespace_id_to_project.rb
+5
-0
db/schema.rb
db/schema.rb
+11
-10
No files found.
app/models/group.rb
View file @
e29ccece
...
@@ -10,26 +10,7 @@
...
@@ -10,26 +10,7 @@
# updated_at :datetime not null
# updated_at :datetime not null
#
#
class
Group
<
ActiveRecord
::
Base
class
Group
<
Namespace
attr_accessible
:code
,
:name
,
:owner_id
has_many
:projects
belongs_to
:owner
,
class_name:
"User"
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:code
,
presence:
true
,
uniqueness:
true
validates
:owner
,
presence:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
def
self
.
search
query
where
(
"name LIKE :query OR code LIKE :query"
,
query:
"%
#{
query
}
%"
)
end
def
to_param
code
end
def
users
def
users
User
.
joins
(
:users_projects
).
where
(
users_projects:
{
project_id:
project_ids
}).
uniq
User
.
joins
(
:users_projects
).
where
(
users_projects:
{
project_id:
project_ids
}).
uniq
end
end
...
...
app/models/namespace.rb
0 → 100644
View file @
e29ccece
class
Namespace
<
ActiveRecord
::
Base
attr_accessible
:code
,
:name
,
:owner_id
has_many
:projects
belongs_to
:owner
,
class_name:
"User"
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:code
,
presence:
true
,
uniqueness:
true
validates
:owner
,
presence:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
def
self
.
search
query
where
(
"name LIKE :query OR code LIKE :query"
,
query:
"%
#{
query
}
%"
)
end
def
to_param
code
end
end
app/models/project.rb
View file @
e29ccece
...
@@ -32,7 +32,8 @@ class Project < ActiveRecord::Base
...
@@ -32,7 +32,8 @@ class Project < ActiveRecord::Base
attr_accessor
:error_code
attr_accessor
:error_code
# Relations
# Relations
belongs_to
:group
belongs_to
:group
,
foreign_key:
"namespace_id"
,
conditions:
'type = Group'
belongs_to
:namespace
belongs_to
:owner
,
class_name:
"User"
belongs_to
:owner
,
class_name:
"User"
has_many
:users
,
through: :users_projects
has_many
:users
,
through: :users_projects
has_many
:events
,
dependent: :destroy
has_many
:events
,
dependent: :destroy
...
@@ -192,4 +193,12 @@ class Project < ActiveRecord::Base
...
@@ -192,4 +193,12 @@ class Project < ActiveRecord::Base
def
gitlab_ci?
def
gitlab_ci?
gitlab_ci_service
&&
gitlab_ci_service
.
active
gitlab_ci_service
&&
gitlab_ci_service
.
active
end
end
def
path_with_namespace
if
namespace
namespace
.
code
+
'/'
+
path
else
path
end
end
end
end
db/migrate/20121122145155_convert_group_to_namespace.rb
0 → 100644
View file @
e29ccece
class
ConvertGroupToNamespace
<
ActiveRecord
::
Migration
def
up
rename_table
'groups'
,
'namespaces'
add_column
:namespaces
,
:type
,
:string
,
null:
true
# Migrate old groups
Namespace
.
update_all
(
type:
'Group'
)
end
def
down
raise
'Rollback is not allowed'
end
end
db/migrate/20121122150932_add_namespace_id_to_project.rb
0 → 100644
View file @
e29ccece
class
AddNamespaceIdToProject
<
ActiveRecord
::
Migration
def
change
rename_column
:projects
,
:group_id
,
:namespace_id
end
end
db/schema.rb
View file @
e29ccece
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
2012112
0113838
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
2012112
2150932
)
do
create_table
"events"
,
:force
=>
true
do
|
t
|
create_table
"events"
,
:force
=>
true
do
|
t
|
t
.
string
"target_type"
t
.
string
"target_type"
...
@@ -25,14 +25,6 @@ ActiveRecord::Schema.define(:version => 20121120113838) do
...
@@ -25,14 +25,6 @@ ActiveRecord::Schema.define(:version => 20121120113838) do
t
.
integer
"author_id"
t
.
integer
"author_id"
end
end
create_table
"groups"
,
:force
=>
true
do
|
t
|
t
.
string
"name"
,
:null
=>
false
t
.
string
"code"
,
:null
=>
false
t
.
integer
"owner_id"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
end
create_table
"issues"
,
:force
=>
true
do
|
t
|
create_table
"issues"
,
:force
=>
true
do
|
t
|
t
.
string
"title"
t
.
string
"title"
t
.
integer
"assignee_id"
t
.
integer
"assignee_id"
...
@@ -88,6 +80,15 @@ ActiveRecord::Schema.define(:version => 20121120113838) do
...
@@ -88,6 +80,15 @@ ActiveRecord::Schema.define(:version => 20121120113838) do
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
end
end
create_table
"namespaces"
,
:force
=>
true
do
|
t
|
t
.
string
"name"
,
:null
=>
false
t
.
string
"code"
,
:null
=>
false
t
.
integer
"owner_id"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
string
"type"
end
create_table
"notes"
,
:force
=>
true
do
|
t
|
create_table
"notes"
,
:force
=>
true
do
|
t
|
t
.
text
"note"
t
.
text
"note"
t
.
string
"noteable_id"
t
.
string
"noteable_id"
...
@@ -117,7 +118,7 @@ ActiveRecord::Schema.define(:version => 20121120113838) do
...
@@ -117,7 +118,7 @@ ActiveRecord::Schema.define(:version => 20121120113838) do
t
.
boolean
"wall_enabled"
,
:default
=>
true
,
:null
=>
false
t
.
boolean
"wall_enabled"
,
:default
=>
true
,
:null
=>
false
t
.
boolean
"merge_requests_enabled"
,
:default
=>
true
,
:null
=>
false
t
.
boolean
"merge_requests_enabled"
,
:default
=>
true
,
:null
=>
false
t
.
boolean
"wiki_enabled"
,
:default
=>
true
,
:null
=>
false
t
.
boolean
"wiki_enabled"
,
:default
=>
true
,
:null
=>
false
t
.
integer
"
group
_id"
t
.
integer
"
namespace
_id"
end
end
create_table
"protected_branches"
,
:force
=>
true
do
|
t
|
create_table
"protected_branches"
,
:force
=>
true
do
|
t
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment