0

I created a table in a Phoenix LiveView app called users. Afterwards I realised that I needed to use mix pow.install for authentication purposes. I remove all the previously generated files regarding the users table, using git hard reset. However, when I try to start phx.server I'm getting a duplicate_table error.

In addition, running /d users in SQL shell clearly indicates that my old table is still there, with the recognisable field names.

Apologies for being so vague, I only started learning Phoenix and related stuff couple of days ago.

I'll be happy to provide any additional information. Suggestion for a more suitable place to ask the question would also be helpful.

  • If you're just started with your app, then maybe `mix ecto.drop` followed by `mix ecto.create` might be the simplest solution? – Mitkins Feb 03 '21 at 05:29
  • @Mitkins Although I do have another table called `boards` created before `users`, out of desperation I tried `mix ecto.drop` but luckily I got the ERROR 55006 (object_in_use). I would like to keep `boards` and related files. – Stevo Ilišković Feb 03 '21 at 07:19
  • You need to stop you app running and make sure you don't have your database opened in an app. – franckstifler Feb 03 '21 at 08:34
  • @franckstifler Thing is, I only want to remove the last table. – Stevo Ilišković Feb 03 '21 at 15:57
  • Assuming the table was added as a single migration, then you could just drop the table and remove the relevant record from `schema_migrations` – Mitkins Feb 03 '21 at 22:02
  • @Mitkins I added the table as `mix phx.gen.live Users user users email password`. Though I don't see the corresponding migration file anymore. I may have already deleted it. – Stevo Ilišković Feb 04 '21 at 12:55
  • Cool. So you should be able to delete it manually. Just look for a migration in `schema_migrations` that doesn't exist in your `migrations` folder - if it's there, delete that too (otherwise you won't be able to `mix ecto.migrate`) – Mitkins Feb 04 '21 at 22:40
  • Hm, it appears there is no schema_migrations folder. Only `\priv\repo\migrations`, with the new [timestamp]_create_users.exs file created by `mix pow.install`. And yes, the process fails only at `mix ecto.migrate`, `mix pow.install` goes through smoothly. – Stevo Ilišković Feb 05 '21 at 08:52
  • Sorry, when I mentioned `schema_migrations` I was referring to the table in the database. There will be an entry in this table for each migration you see under `\priv\repo\migrations`. You need to delete the row that no longer exists in your project – Mitkins Feb 09 '21 at 23:02

0 Answers0