Files
mapknitter/config/initializers/column_definition.rb
Jeffrey Warren 628b8b56f1 Modularization of export code (#341)
* starting to move things into exporter lib, parameterize

* additional mysql2 adapter change, sqlite compatibility

* moved almost all of exporter code into ruby lib

* Try to update GDAL from sources

* Update Dockerfile

* Try running Buster (#186)

* Try running Buster

* Include binary GDal

* Reorder Dockerfile

* Install npm

* Tweak apt command

* Update Dockerfile

* Simplfy

* Rollback ruby upgrade and rather install 2.4.4 from rvm

* Add login shell to support rvm

* Mysql deps

* Include git

* Fix entry command

* Move start command

* Revert "Fix entry command"

This reverts commit 1833f4132009798fb481d9c821eb2c3e3b6e59cc.

* Remove entrypoint from Dockerfile

* Add -l parameter to bash

* More deps

* Bump mysql2 from 0.3.21 to 0.5.2

Bumps [mysql2](https://github.com/brianmario/mysql2) from 0.3.21 to 0.5.2.
- [Release notes](https://github.com/brianmario/mysql2/releases)
- [Changelog](https://github.com/brianmario/mysql2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/brianmario/mysql2/compare/0.3.21...0.5.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* activerecord-mysql2-adapter

* Return to mysql2 < 4 gem and add some grease

* Update exporter_test.rb

* Update exporter_test.rb

* Update exporter.rb

* Update exporter_test.rb
2019-03-16 15:22:52 -04:00

26 lines
1.2 KiB
Ruby

# prior to MySQL5.7, MySQL would silently convert a column that is part of a primary key and is
# DEFAULT NULL into NOT NULL with a default value of 0 (non standard behavior and not a recommended
# practice) As of MySQL 5.7, this column is converted to NOT NULL, but without a default value,
# throwing an error.
# the below customization both prevents that error and standardizes all of the DBs primary key data
# with a SQL compliant syntax. All the primary keys will be sequential numbers starting from 1.
# Plese keep in mind the compatability of this initializer with your db - if you do not want
# all of your primary keys to be sequential numbers then you can customize this function further
# or, alternatively,
# This can also be removed if DEFAULT NULL is removed from all columns;
# Read more at https://github.com/publiclab/mapknitter/pull/323
class ActiveRecord::ConnectionAdapters::ColumnDefinition
if ActiveRecord::Base.connection.adapter_name != 'sqlite3' && ActiveRecord::Base.connection.adapter_name != 'SQLite'
def sql_type
type.to_sym == :primary_key ? 'int(11) auto_increment PRIMARY KEY' : base.type_to_sql(type.to_sym, limit, precision, scale) rescue type
end
end
end