rails-composer icon indicating copy to clipboard operation
rails-composer copied to clipboard

[FEATURE] Support for `db/structure.sql`

Open paulepanter opened this issue 10 years ago • 4 comments

First of all, thank you for this gem!

In some of our projects we use db/structure.sql as with db/schema.rb some PostgreSQL schemas are not supported. Also it looks like it deals better with non-linear migration due to Git merges.

Could such an option be integrated into the Rails Composer or is it an rarely used feature and we should write a template ourselves?

paulepanter avatar Aug 25 '14 09:08 paulepanter

I've never encountered this before but perhaps other people use it. Could you provide more information? Any blog posts or articles describing this?

DanielKehoe avatar Aug 25 '14 10:08 DanielKehoe

Howdy @paulepanter , did you end up writing the template yourselves or do you have any further thoughts on this? :)

Schwad avatar Sep 03 '17 19:09 Schwad

@Schwad, no I did not write a template. From Stack Overflow:

The main difference is that schema.rb is a Ruby representation of the database, and it is generally database-agnostic. structure.sql instead is a SQL representation of the database and it depends on the specific database you selected.

You only use the structure if you have specific database features that you need and that can't be represented by the schema.rb. For example, in the past some people replaced schema.rb with structure.sql in order to use PostgreSQL JSONB fields or foreign key constraints at database level.

Both features are now supported in the migrations, therefore you don't need to switch to structure.sql anymore (in these cases).

In general, I suggest you to use the schema.rb

paulepanter avatar Sep 04 '17 06:09 paulepanter

@paulepanter good to know, thanks for the link! Are you happy with how rails composer is and we can close the issue or is there anything else outstanding you'd like to see done?

Schwad avatar Sep 04 '17 08:09 Schwad