-
-
Save mustmodify/c58414cb98dce848c768581767183438 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
def last_line | |
`wc -l db/schema.rb`.to_i | |
end | |
table_lines = `grep create_table db/schema.rb -n`.split("\n").map{|l| l.gsub(/\:.*/, '').to_i} | |
term = ARGV[0] | |
table_starts = `grep "create_table.*#{term}" db/schema.rb -n`.split("\n") | |
table_starts.each do |ts| | |
table_info = ts.match(/(\d*): create_table "([^"]*)"/) | |
start_line = table_info[1].to_i | |
table_name = table_info[2] | |
end_line=(table_lines.select{|l| l > start_line}.min || last_line)- 3 | |
puts "\n\n\n ====== [ #{table_name} ] =============================" | |
puts `head db/schema.rb -n #{end_line} | tail -n #{end_line - start_line}` | |
end | |
puts | |
puts |
This file contains hidden or 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
jw@logopolis:/projects/client_name/project_name $ script/dt user | |
====== [ users ] ============================= | |
t.string "email", default: "", null: false | |
t.string "password_digest", collation: "utf8mb4_unicode_ci" | |
t.string "persistence_token", collation: "utf8mb4_unicode_ci" | |
t.string "perishable_token", collation: "utf8mb4_unicode_ci" | |
t.string "single_access_token", collation: "utf8mb4_unicode_ci" | |
t.integer "login_count", default: 0 | |
t.datetime "last_request_at" | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
t.index ["email"], name: "index_users_on_email", unique: true, using: :btree | |
This file contains hidden or 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
jw@logopolis:/projects/client_name/project_name $ script/dt user | |
====== [ users ] ============================= | |
t.string "email", default: "", null: false | |
t.string "password_digest", collation: "utf8mb4_unicode_ci" | |
t.string "persistence_token", collation: "utf8mb4_unicode_ci" | |
t.string "perishable_token", collation: "utf8mb4_unicode_ci" | |
t.string "single_access_token", collation: "utf8mb4_unicode_ci" | |
t.integer "login_count", default: 0 | |
t.datetime "last_request_at" | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
t.index ["email"], name: "index_users_on_email", unique: true, using: :btree | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment