How to get the DDL for a RoR application

#1

Hello. I want to first start that I am not a Ruby developer. I work in an EDW (Enterprise data warehouse) which supports many applications built on different technology stacks (Java, Angular JS, Python, Ruby, etc.)

For most of the applications we support we are able to get their DDL (Data Definition Language). DDL contains information of the table structure and metadata (Ex: Column data type (integer, string, boolean, date, timestamp, etc.), column length (varchar 255, number (38), etc.) and other metadata

When I ask Ruby on Rails teams for their DDL, they are not able to provide it. I’m trying to find out what is the best way to:

A) Request table information with the details as mentioned above
B) The proper way to request to the RoR developer so they understand.

As the EDW, we need that information about the source DB so that we can ensure our ETL workflows work correctly as it pulls data and stores in the enterprise ODS (Operational Data Store). Any help regarding A&B would be appreciated. Thank you in advance.

#2

Try with:

Model.columns.map {|col| {name: col.name, type: col.type, precision: col.precision, scale: col.scale, limit: col.limit, sql_type: col.sql_type, null: col.null, default: col.default}}

This returns an array of hashes with the information.

#3

An easier way is to look at the schema.rb file located in /db/schema.rb.

A. This is the entire db schema of the app.
B. Just request the file.