From c1dddf8c7d947691729f6d64a8ea768b5c915855 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Feb 2014 09:45:25 +0100 Subject: [PATCH 1/4] Uniqueness check should be case insensitive for username and path, otherwise mysql behaves weird. --- app/models/namespace.rb | 2 +- app/models/user.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/namespace.rb b/app/models/namespace.rb index d5b98f588e8..0bc5e1862eb 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -27,7 +27,7 @@ class Namespace < ActiveRecord::Base format: { with: Gitlab::Regex.name_regex, message: "only letters, digits, spaces & '_' '-' '.' allowed." } validates :description, length: { within: 0..255 } - validates :path, uniqueness: true, presence: true, length: { within: 1..255 }, + validates :path, uniqueness: { case_sensitive: false }, presence: true, length: { within: 1..255 }, exclusion: { in: Gitlab::Blacklist.path }, format: { with: Gitlab::Regex.path_regex, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } diff --git a/app/models/user.rb b/app/models/user.rb index dd59f67ea3d..855fe58ffe8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -109,7 +109,7 @@ class User < ActiveRecord::Base validates :bio, length: { maximum: 255 }, allow_blank: true validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider} validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} - validates :username, presence: true, uniqueness: true, + validates :username, presence: true, uniqueness: { case_sensitive: false }, exclusion: { in: Gitlab::Blacklist.path }, format: { with: Gitlab::Regex.username_regex, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } From acdb808abc819180529855fa2f919587fa0dec58 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Feb 2014 10:10:25 +0100 Subject: [PATCH 2/4] Update database documentation. --- doc/install/database_mysql.md | 45 ++++++++++++++++++++++++++++++++ doc/install/databases.md | 48 ++--------------------------------- doc/install/installation.md | 2 +- 3 files changed, 48 insertions(+), 47 deletions(-) create mode 100644 doc/install/database_mysql.md diff --git a/doc/install/database_mysql.md b/doc/install/database_mysql.md new file mode 100644 index 00000000000..f0d0e830d4c --- /dev/null +++ b/doc/install/database_mysql.md @@ -0,0 +1,45 @@ +## Note + +We do not recommend using MySQL due to various issues. For example, case [(in)sensitivity](https://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html) and [problems](http://bugs.mysql.com/bug.php?id=65830) that [suggested](http://bugs.mysql.com/bug.php?id=50909) [fixes](http://bugs.mysql.com/bug.php?id=65830) [have](http://bugs.mysql.com/bug.php?id=63164) . + +## MySQL + + # Install the database packages + sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev + + # Pick a database root password (can be anything), type it and press enter + # Retype the database root password and press enter + + # Secure your installation. + sudo mysql_secure_installation + + # Login to MySQL + mysql -u root -p + + # Type the database root password + + # Create a user for GitLab + # do not type the 'mysql>', this is part of the prompt + # change $password in the command below to a real password you pick + mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; + + # Create the GitLab production database + mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; + + # Grant the GitLab user necessary permissions on the table. + mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost'; + + # Quit the database session + mysql> \q + + # Try connecting to the new database with the new user + sudo -u git -H mysql -u git -p -D gitlabhq_production + + # Type the password you replaced $password with earlier + + # You should now see a 'mysql>' prompt + + # Quit the database session + mysql> \q + + # You are done installing the database and can go back to the rest of the installation. diff --git a/doc/install/databases.md b/doc/install/databases.md index 481a698a8c8..b43f6b76b21 100644 --- a/doc/install/databases.md +++ b/doc/install/databases.md @@ -2,52 +2,8 @@ GitLab supports the following databases: -* MySQL (preferred) -* PostgreSQL - - -## MySQL - - # Install the database packages - sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev - - # Pick a database root password (can be anything), type it and press enter - # Retype the database root password and press enter - - # Secure your installation. - sudo mysql_secure_installation - - # Login to MySQL - mysql -u root -p - - # Type the database root password - - # Create a user for GitLab - # do not type the 'mysql>', this is part of the prompt - # change $password in the command below to a real password you pick - mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; - - # Create the GitLab production database - mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; - - # Grant the GitLab user necessary permissions on the table. - mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost'; - - # Quit the database session - mysql> \q - - # Try connecting to the new database with the new user - sudo -u git -H mysql -u git -p -D gitlabhq_production - - # Type the password you replaced $password with earlier - - # You should now see a 'mysql>' prompt - - # Quit the database session - mysql> \q - - # You are done installing the database and can go back to the rest of the installation. - +* PostgreSQL (preferred) +* [MySQL](doc/install/database_mysql.md) ## PostgreSQL diff --git a/doc/install/installation.md b/doc/install/installation.md index dd391eeb4b3..3b009148957 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -144,7 +144,7 @@ GitLab Shell is an ssh access and repository management software developed speci # 5. Database -To setup the MySQL/PostgreSQL database and dependencies please see [doc/install/databases.md](./databases.md). +To setup the PostgreSQL/MySQL database and dependencies please see [doc/install/databases.md](doc/install/databases.md). # 6. GitLab From a7a2100f3d3344669d951665dc8e2253451d859f Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Feb 2014 10:51:58 +0100 Subject: [PATCH 3/4] Doc syntax highlighting. --- doc/install/database_mysql.md | 52 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/doc/install/database_mysql.md b/doc/install/database_mysql.md index f0d0e830d4c..bb4c3e1ede0 100644 --- a/doc/install/database_mysql.md +++ b/doc/install/database_mysql.md @@ -4,42 +4,42 @@ We do not recommend using MySQL due to various issues. For example, case [(in)se ## MySQL - # Install the database packages - sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev + # Install the database packages + sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev - # Pick a database root password (can be anything), type it and press enter - # Retype the database root password and press enter + # Pick a database root password (can be anything), type it and press enter + # Retype the database root password and press enter - # Secure your installation. - sudo mysql_secure_installation + # Secure your installation. + sudo mysql_secure_installation - # Login to MySQL - mysql -u root -p + # Login to MySQL + mysql -u root -p - # Type the database root password + # Type the database root password - # Create a user for GitLab - # do not type the 'mysql>', this is part of the prompt - # change $password in the command below to a real password you pick - mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; + # Create a user for GitLab + # do not type the 'mysql>', this is part of the prompt + # change $password in the command below to a real password you pick + mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; - # Create the GitLab production database - mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; + # Create the GitLab production database + mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; - # Grant the GitLab user necessary permissions on the table. - mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost'; + # Grant the GitLab user necessary permissions on the table. + mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost'; - # Quit the database session - mysql> \q + # Quit the database session + mysql> \q - # Try connecting to the new database with the new user - sudo -u git -H mysql -u git -p -D gitlabhq_production + # Try connecting to the new database with the new user + sudo -u git -H mysql -u git -p -D gitlabhq_production - # Type the password you replaced $password with earlier + # Type the password you replaced $password with earlier - # You should now see a 'mysql>' prompt + # You should now see a 'mysql>' prompt - # Quit the database session - mysql> \q + # Quit the database session + mysql> \q - # You are done installing the database and can go back to the rest of the installation. + # You are done installing the database and can go back to the rest of the installation. From fcdcb1a6751354819410444ae7f38391e64a686d Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Feb 2014 11:42:58 +0100 Subject: [PATCH 4/4] Move database setup guide inside the installation. --- doc/install/database_mysql.md | 2 +- doc/install/databases.md | 27 --------------------------- doc/install/installation.md | 20 +++++++++++++++++++- 3 files changed, 20 insertions(+), 29 deletions(-) delete mode 100644 doc/install/databases.md diff --git a/doc/install/database_mysql.md b/doc/install/database_mysql.md index bb4c3e1ede0..4cf9b94c1a0 100644 --- a/doc/install/database_mysql.md +++ b/doc/install/database_mysql.md @@ -1,6 +1,6 @@ ## Note -We do not recommend using MySQL due to various issues. For example, case [(in)sensitivity](https://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html) and [problems](http://bugs.mysql.com/bug.php?id=65830) that [suggested](http://bugs.mysql.com/bug.php?id=50909) [fixes](http://bugs.mysql.com/bug.php?id=65830) [have](http://bugs.mysql.com/bug.php?id=63164) . +We do not recommend using MySQL due to various issues. For example, case [(in)sensitivity](https://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html) and [problems](http://bugs.mysql.com/bug.php?id=65830) that [suggested](http://bugs.mysql.com/bug.php?id=50909) [fixes](http://bugs.mysql.com/bug.php?id=65830) [have](http://bugs.mysql.com/bug.php?id=63164). ## MySQL diff --git a/doc/install/databases.md b/doc/install/databases.md deleted file mode 100644 index b43f6b76b21..00000000000 --- a/doc/install/databases.md +++ /dev/null @@ -1,27 +0,0 @@ -# Setup Database - -GitLab supports the following databases: - -* PostgreSQL (preferred) -* [MySQL](doc/install/database_mysql.md) - -## PostgreSQL - - # Install the database packages - sudo apt-get install -y postgresql-9.1 postgresql-client libpq-dev - - # Login to PostgreSQL - sudo -u postgres psql -d template1 - - # Create a user for GitLab. - template1=# CREATE USER git; - - # Create the GitLab production database & grant all privileges on database - template1=# CREATE DATABASE gitlabhq_production OWNER git; - - # Quit the database session - template1=# \q - - # Try connecting to the new database with the new user - sudo -u git -H psql -d gitlabhq_production - diff --git a/doc/install/installation.md b/doc/install/installation.md index 3b009148957..44d57b97efb 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -144,7 +144,25 @@ GitLab Shell is an ssh access and repository management software developed speci # 5. Database -To setup the PostgreSQL/MySQL database and dependencies please see [doc/install/databases.md](doc/install/databases.md). +We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](doc/install/database_mysql.md). + + # Install the database packages + sudo apt-get install -y postgresql-9.1 postgresql-client libpq-dev + + # Login to PostgreSQL + sudo -u postgres psql -d template1 + + # Create a user for GitLab. + template1=# CREATE USER git; + + # Create the GitLab production database & grant all privileges on database + template1=# CREATE DATABASE gitlabhq_production OWNER git; + + # Quit the database session + template1=# \q + + # Try connecting to the new database with the new user + sudo -u git -H psql -d gitlabhq_production # 6. GitLab