This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Parse and identify potential foreign key issues in a Rails schema.rb file. | |
# TO USE THIS, SAVE THE FILE AND RUN IT USING RAILS RUNNER. EXAMPLE: | |
# `rails runner missing_fks.rb` | |
def extract_table_names(schema_lines) | |
schema_lines.select { |line| line.strip.start_with?('create_table') } | |
.map { |line| line.split('"')[1] } | |
end |