amnesia icon indicating copy to clipboard operation
amnesia copied to clipboard

How to create a table for existing database

Open jmerriweather opened this issue 9 years ago • 1 comments

I'm trying to create a table in an existing database using exrm's release tasks. How is everyone else doing this? I'm doing it the following way:

def create_table(production_node, database, table_name) do
  {:ok, _} = Application.ensure_all_started(:app)

  # create table
  table_name.create(disk: [production_node])

  IO.puts "Waiting"
  :ok = database.wait(15000)

  IO.puts "Done"
  :init.stop()
end

Could we perhaps put something like this in the readme? Assuming this is correct, should I send a PR?

jmerriweather avatar Aug 02 '16 05:08 jmerriweather

Just wanted to add, don't destroy the metadata. Will reset any indexes.

Updated above comment to remove the following:

 # get metadata for database
  metadata = Amnesia.Metadata.for(database)
  # destroy database metadata table
  metadata |> Amnesia.Metadata.destroy
  # create metadata table
  metadata |> Amnesia.Metadata.create(disk: [production_node])

jmerriweather avatar Apr 10 '17 22:04 jmerriweather