Closed metaskills closed 4 years ago
Hi, It may not be what you are looking for, I have created rails-dev-box
to support SQL Server vNext CTP on Ubuntu 16.10.
https://yahonda.ghost.io/2016/11/19/untitled-3/ https://github.com/yahonda/rails-dev-box/tree/runs_sqlserver
@yahonda Thanks for sharing this. Solid example for me to learn from. I have a few questions:
rails/rails-dev-box
to the rails-sqlserver/rails-dev-box
and mirrored your work? I can then maintain that fork here.I setup some docker images that build off the official microsoft image both for TinyTDS and one for the adapter. For example (https://hub.docker.com/r/metaskills/mssql-server-linux-rails/) the adapter one. I don't suspect I'll use the rails-dev-box often since I am mostly looking at Docker as a way to run the SQL Server DB. To that end, I was thinking of adding a section like this to the adapter's README that would just pull and run that docker image which has the test DB setup. However, looking at the rails-dev-box, I think we should promote dev/contributors on that one too - assuming FreeTDS is installed. Thoughts?
Thank for the reply.
I did not see FreeTDS installed here in your bootstrap script nor what version. How is TinyTDS supposed to install with that setup?
Actually I was not aware of how TinyTDS is installed but actually it is.
$ bundle show tiny_tds
/var/lib/gems/2.3.0/gems/tiny_tds-1.1.0
I am almost new to SQL Server then I'd provide the commands executed and you will see the full (too verbose) output in details section.
$ vagrant up
At guest
$ vagrant ssh
$ git clone https://github.com/rails-sqlserver/activerecord-sqlserver-adapter.git
$ cd activerecord-sqlserver-adapter/
$ bundle install
$ bundle exec rake test
0 packages can be updated. 0 updates are security updates.
ubuntu@rails-dev-box:~$ git clone https://github.com/rails-sqlserver/activerecord-sqlserver-adapter.git
Cloning into 'activerecord-sqlserver-adapter'...
remote: Counting objects: 10616, done.
remote: Compressing objects: 100% (145/145), done.
remote: Total 10616 (delta 77), reused 0 (delta 0), pack-reused 10470
Receiving objects: 100% (10616/10616), 2.44 MiB | 2.59 MiB/s, done.
Resolving deltas: 100% (5182/5182), done.
Checking connectivity... done.
ubuntu@rails-dev-box:~$ cd activerecord-sqlserver-adapter/
ubuntu@rails-dev-box:~/activerecord-sqlserver-adapter$ bundle install
The git source git://github.com/rails/rails.git
uses the git
protocol, which transmits data without encryption. Disable this warning with bundle config git.allow_insecure true
, or switch to the https
protocol to keep your data secure.
Fetching git://github.com/rails/rails.git
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform mingw, mswin, x64_mingw, jruby
.
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Installing rake 12.0.0
Installing concurrent-ruby 1.0.4
Installing i18n 0.7.0
Installing minitest 5.3.3
Installing thread_safe 0.3.5
Installing builder 3.2.3
Installing erubis 2.7.0
Installing mini_portile2 2.1.0
Installing rack 2.0.1
Installing nio4r 1.2.1 with native extensions
Installing websocket-extensions 0.1.2
Installing mime-types-data 3.2016.0521
Installing arel 7.1.4
Installing bcrypt 3.1.11 with native extensions
Using bundler 1.14.0
Installing byebug 9.0.6 with native extensions
Installing coderay 1.1.1
Installing ffi 1.9.17 with native extensions
Installing formatador 0.2.5
Installing rb-fsevent 0.9.8
Installing ruby_dep 1.5.0
Installing lumberjack 1.0.11
Installing nenv 0.3.0
Installing shellany 0.0.1
Installing method_source 0.8.2
Installing slop 3.6.0
Installing thor 0.19.4
Installing guard-compat 1.2.1
Installing metaclass 0.0.4
Installing sqlite3 1.3.13 with native extensions
Installing tzinfo 1.2.2
Installing nokogiri 1.7.0.1 with native extensions
Installing tiny_tds 1.1.0 with native extensions
Installing rack-test 0.6.3
Installing sprockets 3.7.1
Installing websocket-driver 0.6.4 with native extensions
Installing mime-types 3.1
Installing rb-inotify 0.9.7
Installing notiffany 0.1.1
Installing pry 0.10.4
Installing guard-minitest 2.4.6
Installing mocha 1.2.1
Using activesupport 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Installing loofah 2.0.3
Installing mail 2.6.4
Installing listen 3.1.5
Installing rails-dom-testing 2.0.2
Installing globalid 0.3.7
Using activemodel 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Installing rails-html-sanitizer 1.0.3
Installing guard 2.14.0
Using activejob 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Using activerecord 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Using actionview 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Using activerecord-sqlserver-adapter 5.0.1 from source at .
Using actionpack 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Using actioncable 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Using actionmailer 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Using railties 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Installing sprockets-rails 3.2.0
Using rails 5.0.1 from git://github.com/rails/rails.git (at v5.0.1@3843ee5)
Installing minitest-spec-rails 5.4.0
Bundle complete! 12 Gemfile dependencies, 62 gems now installed.
Use bundle show [gemname]
to see where a bundled gem is installed.
ubuntu@rails-dev-box:~/activerecord-sqlserver-adapter$ bundle exec rake test
Using dblib
🐵 Undefined coerced test: UniquenessValidationTest#test_validate_uniqueness_with_limit
🐵 Undefined coerced test: UniquenessValidationTest#test_validate_uniqueness_with_limit_and_utf8
🐵 Undefined coerced test: ActiveRecord::AdapterTest#test_update_prepared_statement
🐵 Undefined coerced test: ActiveRecord::AdapterTest#test_value_limit_violations_are_translated_to_specific_exception
🐵 Undefined coerced test: AttributeMethodsTest#test_typecast_attribute_from_select_to_false
🐵 Undefined coerced test: AttributeMethodsTest#test_typecast_attribute_from_select_to_true
🐵 Undefined coerced test: BasicsTest#test_column_names_are_escaped
🐵 Undefined coerced test: BasicsTest#test_numeric_fields
🐵 Undefined coerced test: BasicsTest#test_numeric_fields_with_scale
🐵 Undefined coerced test: BasicsTest#test_respect_internal_encoding
🐵 Undefined coerced test: BasicsTest#test_find_keeps_multiple_group_values
🐵 Undefined coerced test: BelongsToAssociationsTest#test_belongs_to_does_not_use_order_by
🐵 Undefined coerced test: BelongsToAssociationsTest#test_belongs_to_with_primary_key_joins_on_correct_column
🐵 Undefined coerced test: ActiveRecord::BindParameterTest#test_binds_are_logged
🐵 Undefined coerced test: CalculationsTest#test_should_return_decimal_average_of_integer_field
🐵 Undefined coerced test: CalculationsTest#test_limit_is_kept
🐵 Undefined coerced test: CalculationsTest#test_limit_with_offset_is_kept
🐵 Undefined coerced test: CalculationsTest#test_having_with_strong_parameters
🐵 Undefined coerced test: ActiveRecord::Migration::ChangeSchemaTest#test_create_table_with_bigint
🐵 Undefined coerced test: ActiveRecord::Migration::ChangeSchemaTest#test_create_table_with_defaults
🐵 Undefined coerced test: ActiveRecord::Migration::ChangeSchemaWithDependentObjectsTest#test_create_table_with_force_cascade_drops_dependent_objects
🐵 Undefined coerced test: ActiveRecord::Migration::ColumnAttributesTest#test_add_column_without_limit
🐵 Undefined coerced test: ActiveRecord::Migration::ColumnsTest#test_rename_column_preserves_default_value_not_null
🐵 Undefined coerced test: ActiveRecord::Migration::ColumnsTest#test_remove_column_with_multi_column_index
🐵 Undefined coerced test: ActiveRecord::Migration::ColumnsTest#test_rename_nonexistent_column
🐵 Undefined coerced test: MigrationTest#test_add_table_with_decimals
🐵 Undefined coerced test: MigrationTest#test_migration_sets_internal_metadata_even_when_fully_migrated
🐵 Undefined coerced test: MigrationTest#test_internal_metadata_stores_environment
🐵 Undefined coerced test: CoreTest#test_pretty_print_persisted
🙉 🙈 🙊 Undefined all tests: ActiveRecord::ConnectionAdapters::TypeLookupTest
🙉 🙈 🙊 Undefined all tests: ActiveRecord::ConnectionAdapters::MergeAndResolveDefaultUrlConfigTest
🐵 Undefined coerced test: ActiveRecord::DatabaseTasksCreateAllTest#test_ignores_remote_databases
🐵 Undefined coerced test: ActiveRecord::DatabaseTasksCreateAllTest#test_warning_for_remote_databases
🐵 Undefined coerced test: ActiveRecord::DatabaseTasksDropAllTest#test_ignores_remote_databases
🐵 Undefined coerced test: ActiveRecord::DatabaseTasksDropAllTest#test_warning_for_remote_databases
🐵 Undefined coerced test: DefaultScopingTest#test_order_in_default_scope_should_not_prevail
🐵 Undefined coerced test: DefaultScopingTest#test_with_abstract_class_scope_should_be_executed_in_correct_context
🐵 Undefined coerced test: EachTest#test_find_in_batches_should_quote_batch_order
🐵 Undefined coerced test: EachTest#test_in_batches_should_quote_batch_order
🐵 Undefined coerced test: EagerAssociationTest#test_count_with_include
🐵 Undefined coerced test: EagerAssociationTest#test_0013_including association based on sql condition and no database column
🐵 Undefined coerced test: FinderTest#test_0006_find_by doesn't have implicit ordering
🐵 Undefined coerced test: FinderTest#test_0010_find_by! doesn't have implicit ordering
🐵 Undefined coerced test: FinderTest#test_find_doesnt_have_implicit_ordering
🐵 Undefined coerced test: FinderTest#test_exists_does_not_select_columns_without_alias
🐵 Undefined coerced test: FinderTest#test_string_sanitation
🐵 Undefined coerced test: FinderTest#test_take_and_first_and_last_with_integer_should_use_sql_limit
🐵 Undefined coerced test: FinderTest#test_find_with_order_on_included_associations_with_construct_finder_sql_for_association_limiting_and_is_distinct
🐵 Undefined coerced test: FinderTest#test_condition_utc_time_interpolation_with_default_timezone_local
🐵 Undefined coerced test: FinderTest#test_condition_local_time_interpolation_with_default_timezone_utc
🐵 Undefined coerced test: ActiveRecord::Migration::ForeignKeyTest#test_add_on_delete_restrict_foreign_key
🐵 Undefined coerced test: HasOneAssociationsTest#test_has_one_does_not_use_order_by
🐵 Undefined coerced test: InheritanceTest#test_a_bad_type_column
🐵 Undefined coerced test: InheritanceTest#test_eager_load_belongs_to_primary_key_quoting
🐵 Undefined coerced test: LeftOuterJoinAssociationTest#test_does_not_override_select
🐵 Undefined coerced test: NamedScopingTest#test_scopes_honor_current_scopes_from_when_defined
🐵 Undefined coerced test: NestedRelationScopingTest#test_merge_options
🐵 Undefined coerced test: PersistenceTest#test_update_columns_changing_id
🐵 Undefined coerced test: PersistenceTest#test_update_all_doesnt_ignore_order
🐵 Undefined coerced test: PersistenceTest#test_update_attributes
🐵 Undefined coerced test: ActiveRecord::PredicateBuilderTest#test_registering_new_handlers
🐵 Undefined coerced test: QueryCacheTest#test_cache_does_not_wrap_string_results_in_arrays
🐵 Undefined coerced test: RelationTest#test_reverse_order_with_function
🐵 Undefined coerced test: RelationTest#test_reverse_order_with_function_other_predicates
🐵 Undefined coerced test: RelationTest#test_0005_find_by doesn't have implicit ordering
🐵 Undefined coerced test: RelationTest#test_0010_find_by! doesn't have implicit ordering
🐵 Undefined coerced test: RelationTest#test_order_using_scoping
🐵 Undefined coerced test: RelationTest#test_default_scope_order_with_scope_order
🐵 Undefined coerced test: RelationTest#test_multiple_where_and_having_clauses
🐵 Undefined coerced test: RelationTest#test_having_with_binds_for_both_where_and_having
🐵 Undefined coerced test: SanitizeTest#test_sanitize_sql_like_example_use_case
🐵 Undefined coerced test: SchemaDumperTest#test_schema_dump_keeps_large_precision_integer_columns_as_decimal
🐵 Undefined coerced test: SchemaDumperTest#test_types_line_up
🐵 Undefined coerced test: SchemaDumperTest#test_foreign_keys_are_dumped_at_the_bottom_to_circumvent_dependency_issues
🐵 Undefined coerced test: SchemaDumperTest#test_schema_dumps_partial_indices
🐵 Undefined coerced test: SchemaDumperTest#test_schema_dump_includes_decimal_options
🐵 Undefined coerced test: SchemaDumperDefaultsTest#test_schema_dump_defaults_with_universally_supported_types
🐵 Undefined coerced test: TransactionTest#test_releasing_named_savepoints
🐵 Undefined coerced test: TransactionIsolationTest#test_0002_read committed
🐵 Undefined coerced test: TransactionIsolationTest#test_0003_repeatable read
🐵 Undefined coerced test: ViewWithPrimaryKeyTest#test_views
🐵 Undefined coerced test: ViewWithPrimaryKeyTest#test_does_not_assume_id_column_as_primary_key
🐵 Undefined coerced test: ViewWithoutPrimaryKeyTest#test_views
🐵 Undefined coerced test: YamlSerializationTest#test_types_of_virtual_columns_are_not_changed_on_round_trip
🐵 Undefined coerced test: DateTimePrecisionTest#test_invalid_datetime_precision_raises_error
🐵 Undefined coerced test: DefaultNumbersTest#test_default_positive_integer
🐵 Undefined coerced test: DefaultNumbersTest#test_default_negative_integer
🐵 Undefined coerced test: ActiveRecord::CollectionCacheKeyTest#test_0011_cache_key for queries with offset which return 0 rows
Run options: --seed 27497
......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S.......................................................................................................................................................................................................................................................................EE................
Finished in 495.914262s, 9.7759 runs/s, 28.6279 assertions/s.
1) Error:
SQLServerRakeStructureDumpLoadTest#test_0001_dumps structure and accounts for defncopy oddities:
Errno::ENOENT: No such file or directory @ rb_sysopen - /home/ubuntu/activerecord-sqlserver-adapter/test/migrations/structure.sql
/home/ubuntu/activerecord-sqlserver-adapter/lib/active_record/tasks/sqlserver_database_tasks.rb:65:in read' /home/ubuntu/activerecord-sqlserver-adapter/lib/active_record/tasks/sqlserver_database_tasks.rb:65:in
structure_dump'
/home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activerecord/lib/active_record/tasks/database_tasks.rb:207:in structure_dump' /home/ubuntu/activerecord-sqlserver-adapter/test/cases/rake_test_sqlserver.rb:151:in
block (2 levels) in block (2 levels) in quietly' /home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activesupport/lib/active_support/testing/stream.rb:10:in
silence_stream'
/home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activesupport/lib/active_support/testing/stream.rb:18:in block in quietly' /home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activesupport/lib/active_support/testing/stream.rb:10:in
silence_stream'
/home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activesupport/lib/active_support/testing/stream.rb:17:in quietly' /home/ubuntu/activerecord-sqlserver-adapter/test/cases/rake_test_sqlserver.rb:151:in
block in
2) Error:
SQLServerRakeStructureDumpLoadTest#test_0002_can load dumped structure:
Errno::ENOENT: No such file or directory @ rb_sysopen - /home/ubuntu/activerecord-sqlserver-adapter/test/migrations/structure.sql
/home/ubuntu/activerecord-sqlserver-adapter/lib/active_record/tasks/sqlserver_database_tasks.rb:65:in read' /home/ubuntu/activerecord-sqlserver-adapter/lib/active_record/tasks/sqlserver_database_tasks.rb:65:in
structure_dump'
/home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activerecord/lib/active_record/tasks/database_tasks.rb:207:in structure_dump' /home/ubuntu/activerecord-sqlserver-adapter/test/cases/rake_test_sqlserver.rb:161:in
block (2 levels) in block (2 levels) in quietly' /home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activesupport/lib/active_support/testing/stream.rb:10:in
silence_stream'
/home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activesupport/lib/active_support/testing/stream.rb:18:in block in quietly' /home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activesupport/lib/active_support/testing/stream.rb:10:in
silence_stream'
/home/ubuntu/.bundle/ruby/2.3.0/rails-3843ee5ac37f/activesupport/lib/active_support/testing/stream.rb:17:in quietly' /home/ubuntu/activerecord-sqlserver-adapter/test/cases/rake_test_sqlserver.rb:161:in
block in
4848 runs, 14197 assertions, 0 failures, 2 errors, 3 skips
You have skipped tests. Run with --verbose for details. rake aborted! Command failed with status (1) /var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>' Tasks: TOP => test => test:dblib (See full trace by running task with --trace)
Would you mind if I cloned the rails/rails-dev-box to the rails-sqlserver/rails-dev-box and mirrored your work? I can then maintain that fork here.
Sure. Please feel free to fork it. I think it is good idea to be maintained here 👍
Thanks! When this ran on the host:
Installing tiny_tds 1.1.0 with native extensions
I suspect it used Miniportile to install FreeTDS which is something we want to change since Miniportile is really only used for doing the precompiled Windows binaries. I'll take that into account when doing the rails-dev-box fork. Really appreciate it!!!
First few lines of my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~>5.0.0'
# Use sqlserver as the database for Active Record
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'#, '4.2.4' # Going higher on this may fail tests!
The Dockerfile:
FROM ruby:2.3.3-onbuild
Not much to it.
I keep the db in a different container.
We compile freetds from .tar.gz in our Dockerfile (which we base on the great phusion/passenger-ruby24
image which comes together with -you guessed it- the Phusion Passenger server):
RUN set -xe \
&& FREETDS_DOWNLOAD_URL="http://www.freetds.org/files/stable/freetds-1.00.80.tar.gz" \
&& FREETDS_DOWNLOAD_SHA256="c5721eeed39372edd4831daf2e309a859f5682a27df8ae8e7dd71da666807497" \
&& apt-get install -y curl build-essential \
&& curl -fSL -o freetds.tar.gz $FREETDS_DOWNLOAD_URL \
&& echo "$FREETDS_DOWNLOAD_SHA256 freetds.tar.gz" | sha256sum -c - \
&& mkdir freetds \
&& tar -xzf freetds.tar.gz --strip 1 -C freetds \
&& cd freetds \
&& ./configure --prefix=/usr/local --with-tdsver=7.3 \
&& make \
&& make install \
&& cd .. \
&& rm -rf freetds freetds.tar.gz
In the Gemfile
we use the typical:
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~> 5.1'
Maybe that is of assistance to anyone :)
Just tossing in my freetds install dockerfile that I use on my images, in case it's helpful for anyone.
FROM ruby:2.4
# Set this to the version of TDS you wish to load.
# You can change it at build time with
# docker build --args FREETDS=freetds-1.00.82
ARG FREETDS=freetds-1.00.82
###
# Setting up Free TDS for SQL Server connectivity
# Build Dependencies
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \
apt-get install -y wget build-essential libc6-dev && \
apt-get clean
# Download Free TDS and cleanup
RUN wget http://www.freetds.org/files/stable/$FREETDS.tar.gz && \
tar -xvf $FREETDS.tar.gz -C /opt && \
rm $FREETDS.tar.gz
WORKDIR /opt/$FREETDS
# Install Free TDS
RUN ./configure --prefix=/usr/local --with-tdsver=7.3 && \
make && \
make install && \
cd .. && rm -rf $FREETDS
Closing this now that we have a vagrant box and a docker image for CI.