Do you have an example how to use schema and migrations with your library?
sheshankkodam opened this issue · comments
Hi @sheshankkodam - yes, we provide documentation in the migration module itself - see the moduledoc in https://github.com/circles-learning-labs/ecto_adapters_dynamodb/blob/master/lib/ecto_adapters_dynamodb/migration.ex for examples of migrations.
Does that help?
Sure. There are some good examples there.
But I'm receiving this error when executing mix ecto.migrate --step 0
command.
2019-04-02 13:58:46.475 [debug] Request URL: "http://localhost:8084/"
2019-04-02 13:58:46.476 [debug] Request HEADERS: [{"Authorization", "AWS4-HMAC-SHA256 Credential=1234/20190402/us-west-1/dynamodb/aws4_request,SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,Signature=f73561e6e8948e5d2a5e8a7b689cee1fc517e8851825280316c949ce88ba6299"}, {"host", "localhost:8084"}, {"x-amz-date", "20190402T195846Z"}, {"x-amz-content-sha256", ""}, {"x-amz-target", "DynamoDB_20120810.ListTables"}, {"content-type", "application/x-amz-json-1.0"}]
2019-04-02 13:58:46.476 [debug] Request BODY: "{}"
{"message":"2019-4-2 19:58:46 UTC [Ecto dynamo info] Ecto.Adapters.DynamoDB.Migration.execute_ddl: :create_if_not_exists (table)","attributes":{}}
{"message":"2019-4-2 19:58:46 UTC [Ecto dynamo info] Ecto.Adapters.DynamoDB.Migration.execute_ddl: create_if_not_exists: table already exists.","attributes":{"table_name":":schema_migrations"}}
{"message":"2019-4-2 19:58:46 UTC [Ecto dynamo info] Ecto.Adapters.DynamoDB.execute: :all","attributes":{"Ecto.Adapters.DynamoDB.execute-all-vars":{"updated_opts":["{:recursive, true}"],"table":"schema_migrations","lookup_fields":[]}}}
2019-04-02 13:58:46.683 [error] Could not retrieve migrated versions. This error usually happens due to the following:
* The database does not exist
* The "schema_migrations" table, which Ecto uses for managing
migrations, was defined by another library
To fix the first issue, run "mix ecto.create".
To address the second, you can run "mix ecto.drop" followed by
"mix ecto.create". Alternatively you may configure Ecto to use
another table for managing migrations:
config :figment, Figment.DynamoDbRepo,
migration_source: "some_other_table_for_schema_migrations"
The full error report is shown below.
** (ArgumentError) Scan option or configuration have not been specified, and could not confirm the table, "schema_migrations", as listed for scan or caching in the application's configuration. Please see README file for details.
(ecto_adapters_dynamodb) lib/ecto_adapters_dynamodb/query.ex:551: Ecto.Adapters.DynamoDB.Query.maybe_scan_error/1
(ecto_adapters_dynamodb) lib/ecto_adapters_dynamodb.ex:220: Ecto.Adapters.DynamoDB.execute/6
(ecto) lib/ecto/repo/queryable.ex:133: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:37: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/migrator.ex:300: Ecto.Migrator.verbose_schema_migration/3
(ecto) lib/ecto/migrator.ex:157: Ecto.Migrator.run/4
(ecto) lib/mix/tasks/ecto.migrate.ex:83: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
(elixir) lib/enum.ex:769: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:769: Enum.each/2
(mix) lib/mix/task.ex:331: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2
(elixir) lib/code.ex:767: Code.require_file/2
@sheshankkodam note this line in the error message:
** (ArgumentError) Scan option or configuration have not been specified, and could not confirm the table, "schema_migrations", as listed for scan or caching in the application's configuration. Please see README file for details.
You'll need to set the schema_migrations
table as "scannable" in your app's configuration. For example, here's a config I use:
config :ecto_adapters_dynamodb,
remove_nil_fields_on_update: true,
insert_nil_fields: false,
scan_tables: ["schema_migrations"]
That worked. Thanks Darren.
@sheshankkodam Excellent! Thanks so much for your interest in our project.