├── test ├── test_helper.exs └── new_relic_ecto_test.exs ├── README.md ├── .formatter.exs ├── docker-compose.yml ├── .travis.yml ├── .gitignore ├── mix.exs ├── config └── config.exs └── mix.lock /test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ### Deprecated! 3 | 4 | Part of the `new_relic_agent` now 5 | -------------------------------------------------------------------------------- /.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"], 4 | import_deps: [:ecto, :ecto_sql] 5 | ] 6 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.1' 2 | 3 | services: 4 | db: 5 | image: postgres 6 | environment: 7 | POSTGRES_PASSWORD: password 8 | ports: 9 | - 9999:5432 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: elixir 2 | elixir: 1.7.3 3 | otp_release: 4 | - 21.2 5 | notifications: 6 | email: 7 | - vince@newrelic.com 8 | services: 9 | - docker 10 | script: 11 | - docker-compose up -d 12 | - mix format --check-formatted 13 | - mix test 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where 3rd-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | new_relic_ecto-*.tar 24 | 25 | -------------------------------------------------------------------------------- /mix.exs: -------------------------------------------------------------------------------- 1 | defmodule NewRelicEcto.MixProject do 2 | use Mix.Project 3 | 4 | def project do 5 | [ 6 | app: :new_relic_ecto, 7 | description: "[Deprecated] Part of the `new_relic_agent` now", 8 | version: "0.0.0", 9 | elixir: "~> 1.7", 10 | start_permanent: Mix.env() == :prod, 11 | name: "New Relic Ecto", 12 | package: package(), 13 | deps: deps() 14 | ] 15 | end 16 | 17 | # Run "mix help compile.app" to learn about applications. 18 | def application do 19 | [ 20 | extra_applications: [:logger] 21 | ] 22 | end 23 | 24 | defp package do 25 | [ 26 | maintainers: ["Vince Foley"], 27 | licenses: ["Apache 2.0"], 28 | links: %{"GitHub" => "https://github.com/binaryseed/new_relic_ecto"} 29 | ] 30 | end 31 | 32 | # Run "mix help deps" to learn about dependencies. 33 | defp deps do 34 | [ 35 | {:ex_doc, ">= 0.0.0", only: :dev}, 36 | {:ecto_sql, "~> 3.0"}, 37 | {:postgrex, ">= 0.0.0", only: :test} 38 | ] 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /config/config.exs: -------------------------------------------------------------------------------- 1 | # This file is responsible for configuring your application 2 | # and its dependencies with the aid of the Mix.Config module. 3 | use Mix.Config 4 | 5 | # This configuration is loaded before any dependency and is restricted 6 | # to this project. If another project depends on this project, this 7 | # file won't be loaded nor affect the parent project. For this reason, 8 | # if you want to provide default values for your application for 9 | # 3rd-party users, it should be done in your "mix.exs" file. 10 | 11 | # You can configure your application as: 12 | # 13 | # config :new_relic_ecto, key: :value 14 | # 15 | # and access this configuration in your application as: 16 | # 17 | # Application.get_env(:new_relic_ecto, :key) 18 | # 19 | # You can also configure a 3rd-party app: 20 | # 21 | # config :logger, level: :info 22 | # 23 | 24 | # It is also possible to import configuration files, relative to this 25 | # directory. For example, you can emulate configuration per environment 26 | # by uncommenting the line below and defining dev.exs, test.exs and such. 27 | # Configuration from the imported file will override the ones defined 28 | # here (which is why it is important to import them last). 29 | # 30 | # import_config "#{Mix.env()}.exs" 31 | -------------------------------------------------------------------------------- /test/new_relic_ecto_test.exs: -------------------------------------------------------------------------------- 1 | defmodule NewRelicEctoTest do 2 | use ExUnit.Case 3 | 4 | defmodule TestRepo do 5 | use Ecto.Repo, otp_app: :new_relic_ecto, adapter: Ecto.Adapters.Postgres 6 | end 7 | 8 | defmodule TestMigration do 9 | use Ecto.Migration 10 | 11 | def up do 12 | create table("items") do 13 | add :name, :string 14 | end 15 | end 16 | end 17 | 18 | defmodule Item do 19 | use Ecto.Schema 20 | 21 | schema "items" do 22 | field :name 23 | end 24 | end 25 | 26 | @port 9999 27 | @config [ 28 | database: "new_relic_ecto", 29 | username: "postgres", 30 | password: "password", 31 | hostname: "localhost", 32 | port: @port 33 | ] 34 | Application.put_env(:new_relic_ecto, :ecto_repos, [__MODULE__.TestRepo]) 35 | Application.put_env(:new_relic_ecto, __MODULE__.TestRepo, @config) 36 | 37 | test "Setup and query the DB" do 38 | import Ecto.Query 39 | 40 | Ecto.Adapters.Postgres.storage_down(@config) 41 | :ok = Ecto.Adapters.Postgres.storage_up(@config) 42 | TestRepo.start_link() 43 | Ecto.Migrator.run(TestRepo, [{0, TestMigration}], :up, all: true) 44 | 45 | {:ok, _} = TestRepo.insert(%Item{name: "first"}) 46 | {:ok, _} = TestRepo.insert(%Item{name: "second"}) 47 | {:ok, _} = TestRepo.insert(%Item{name: "third"}) 48 | 49 | items = TestRepo.all(from(i in Item)) 50 | 51 | assert length(items) == 3 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /mix.lock: -------------------------------------------------------------------------------- 1 | %{ 2 | "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, 3 | "db_connection": {:hex, :db_connection, "2.0.3", "b4e8aa43c100e16f122ccd6798cd51c48c79fd391c39d411f42b3cd765daccb0", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, 4 | "decimal": {:hex, :decimal, "1.6.0", "bfd84d90ff966e1f5d4370bdd3943432d8f65f07d3bab48001aebd7030590dcc", [:mix], [], "hexpm"}, 5 | "earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"}, 6 | "ecto": {:hex, :ecto, "3.0.5", "bf9329b56f781a67fdb19e92e6d9ed79c5c8b31d41653b79dafb7ceddfbe87e0", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, 7 | "ecto_sql": {:hex, :ecto_sql, "3.0.3", "dd17f2401a69bb2ec91d5564bd259ad0bc63ee32c2cb2e616d04f1559801dba6", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.1", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.2.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, 8 | "ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, 9 | "makeup": {:hex, :makeup, "0.5.5", "9e08dfc45280c5684d771ad58159f718a7b5788596099bdfb0284597d368a882", [:mix], [{:nimble_parsec, "~> 0.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, 10 | "makeup_elixir": {:hex, :makeup_elixir, "0.10.0", "0f09c2ddf352887a956d84f8f7e702111122ca32fbbc84c2f0569b8b65cbf7fa", [:mix], [{:makeup, "~> 0.5.5", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, 11 | "nimble_parsec": {:hex, :nimble_parsec, "0.4.0", "ee261bb53214943679422be70f1658fff573c5d0b0a1ecd0f18738944f818efe", [:mix], [], "hexpm"}, 12 | "postgrex": {:hex, :postgrex, "0.14.1", "63247d4a5ad6b9de57a0bac5d807e1c32d41e39c04b8a4156a26c63bcd8a2e49", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, 13 | "telemetry": {:hex, :telemetry, "0.2.0", "5b40caa3efe4deb30fb12d7cd8ed4f556f6d6bd15c374c2366772161311ce377", [:mix], [], "hexpm"}, 14 | } 15 | --------------------------------------------------------------------------------