Skip to content

Commit eca5927

Browse files
committed
Use the same create database option as Rails Rakefile
* DEFAULT CHARACTER SET utf8mb4 for MySQL https://github.com/rails/rails/blob/5431e17733366da1fd10f2cd3039d66a56012683/activerecord/Rakefile#L97-L98 ``` %x( mysql --user=#{config["arunit"]["username"]} --password=#{config["arunit"]["password"]} -e "create DATABASE #{config["arunit"]["database"]} DEFAULT CHARACTER SET utf8mb4" ) %x( mysql --user=#{config["arunit2"]["username"]} --password=#{config["arunit2"]["password"]} -e "create DATABASE #{config["arunit2"]["database"]} DEFAULT CHARACTER SET utf8mb4" ) ``` * Do not specify `DEFAULT COLLATE` as Rails Raketask removed rails/rails@d54d0c9#diff-6c25b8e13c63a297ab5298948548caef > There should be no "one size fits all" collation in MySQL 5.7. > Let MySQL server choose the default collation for Active Record > unit test databases. * Use `-E UTF8 -T template0` option for PostgreSQL database https://github.com/rails/rails/blob/5431e17733366da1fd10f2cd3039d66a56012683/activerecord/Rakefile#L116-L117 ``` %x( createdb -E UTF8 -T template0 #{config["arunit"]["database"]} ) %x( createdb -E UTF8 -T template0 #{config["arunit2"]["database"]} ) ```
1 parent c1d0670 commit eca5927

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bootstrap.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ install RabbitMQ rabbitmq-server
3434

3535
install PostgreSQL postgresql postgresql-contrib libpq-dev
3636
sudo -u postgres createuser --superuser vagrant
37-
sudo -u postgres createdb -O vagrant activerecord_unittest
38-
sudo -u postgres createdb -O vagrant activerecord_unittest2
37+
sudo -u postgres createdb -O vagrant -E UTF8 -T template0 activerecord_unittest
38+
sudo -u postgres createdb -O vagrant -E UTF8 -T template0 activerecord_unittest2
3939

4040
debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
4141
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
4242
install MySQL mysql-server libmysqlclient-dev
4343
# Set the password in an environment variable to avoid the warning issued if set with `-p`.
4444
MYSQL_PWD=root mysql -uroot <<SQL
4545
CREATE USER 'rails'@'localhost';
46-
CREATE DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
47-
CREATE DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
46+
CREATE DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8mb4;
47+
CREATE DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8mb4;
4848
GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost';
4949
GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost';
5050
GRANT ALL PRIVILEGES ON inexistent_activerecord_unittest.* to 'rails'@'localhost';

0 commit comments

Comments
 (0)