Does this schema make sense?

Hello everyone, I’m in the process of converting a php project that I started some time ago to Rails.

I didn’t plan the php project and the code is pretty crappy. A fresh start makes sense to me, and I wanted to do that in Rails and I want to expand the project.

The PHP project is actually just a hashtag system that can categorize images and it currently looks like this.


I’m not that good in Rails and now I want to ask you if my approach is ok so far.

Here is my current build.

rails new \
  -d postgresql \
  -j webpack \
  --skip-test \

cd HIA-Test
echo 'gem "devise"' >> Gemfile
bundle install
rails g devise:install
rails generate devise User
rails db:migrate
git add . && git commit -m "rails new + devise:install"
rails g model user_details user_name:string first_name:string last_name:string user:references
rails g model picture path:string user:references
rails g model hashtag hashtag:string
rails g model picture_hashtag hashtag:references picture:references
rails g model bookmark picture:references user:references
rails db:migrate
git add . && git commit -m "models"

I didn’t want to add “user-details” to the “user devise”. That’s why I created an extra table for the user info.

rails g model picture path:string is probably not needed at all. Because of Active Storage. Right? But I need to import from mysql to postgreSQL. I still don’t know how to do that either.

What do you think???

Like I said. I’m not that good at Rails and programming in general. So please don’t be so harsh :slight_smile:

Gruß Tron

1 Like

You’re welcome to make this split. Due to the way Devise is maintained, the added table does not gain you much.

Depending on the size of your current database, you might want to tailor your migration.

If it’s small enough, you could make REST calls into your new app.

If data is larger, you might look at keeping your database schema nearly the same and then making text edits to the sql db export from MySQL. Rails can map your model columns to any column and table names you have from your existing schema. You can always evolve from there.

Starting a new project can be a lot of fun so I wish you best on this fresh start.

Hello Eric, thank you for your help.

What do you mean with that, doesn’t that work or is it unnecessary?

I made a few changes to the schema. Does this scheme make more sense and can it work like this?

I meant it’s unnecessary to split the table. Your code can be expected to continue to work as devise is updated into the future.

At a quick glance, your schema looks good.