How to reset postgresql in production on fly

I would like to reset postgresql. How please

I’m using this in a current project. Maybe it is useful to you:

  def drop_all_tables do
    for repo <- repos() do
      from(pg_tables in "pg_tables",
        where: pg_tables.schemaname == "public",
        select: [pg_tables.tablename]
      )
      |> repo.all()
      |> Enum.map(fn [table_name] ->
        repo.query("DROP TABLE #{table_name} CASCADE")
      end)
    end

Thank you. But how to reset it so that it does migration too

mix ecto.reset means: drop db, create db, run migrations, run seeds

Dropping all tables is equivalent to the first 2 steps. So you additionally run migrations (mix ecto.migrate) and seed the db (mix run priv/repo/seeds.exs)

Please note that I’ve never used fly.io. So there is a chance that dropping all tables is not a good idea. You could replace the Enum.map(..) with IO.inspect() to first check that the selected tables are all familiar to you.