amnesia
amnesia copied to clipboard
How to create a table for existing database
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?
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])