3

I'm using bcrypt for Rails API authentication - This is ofc after many hours of trying to figure out how to get Devise to work via Rails api to no avail. (trying to do API only with React frontend).

Anyways, I made it until technical debt had to be paid. BCrypt password_digest and Devise Hashed_password are at a stalemate and I can't seem to get one to ignore the other. I need to change that portion of the schema to accommodate for bcrypt. What's the best way to go about this?

CoderDude
  • 303
  • 2
  • 8
  • 3
    You can but you should not, it's open to human error – benjessop Aug 17 '20 at 09:25
  • 3
    @benjessop everything is prone to human error. Migrations are just less prone then manually repeating transformations across databases. This question also really just smacks of the X&Y problem. The asker thinks migrations are the problem but is not telling us anything about what the changes entail or why the migrations are not working. – max Aug 17 '20 at 11:52
  • So the real question here isn't if you can change the schema, but how to use a single column for storing the password ? Also, is the `reactjs` tag relevant to the question? – Viktor Aug 17 '20 at 12:29

1 Answers1

3

Doing database transformations without using migrations is as easy as running rails db which will start the CLI for your database and typing the SQL. But then you have to repeat those steps across the test/development/production databases and make sure any other developers working on the project also perform those steps on their local databases.

This is a really error prone process and actually solving the problem with migrations is probably a lot less insurmountable than you think.

What's the best way to go about this?

The best solution to ignorance is knowledge.

ActiveRecord migrations are just a Domain Specific Language (DSL) to create SQL queries and a mechanism to run migrations against different databases and keep tabs on which migrations have been run through a metadata table in the database.

Even if you can't express whatever query you are trying to perform through the DSL you can still use any arbitrary SQL string.

max
  • 96,212
  • 14
  • 104
  • 165