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
# in psql prompt | |
# connect to db | |
\c databasename | |
# update counter | |
SELECT setval('tablename_columnname_seq', (SELECT MAX(columnname) FROM tablename)+1); | |
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
git config alias.co checkout | |
git config alias.com commit | |
git config alias.pu !"git fetch origin -v; git fetch upstream -v; git merge upstream/master" | |
git config alias.mrg '!git commit -m "merge"' |
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
git fetch upstream | |
git merge upstream/master |
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
1) backup production database: | |
heroku pgbackups:capture --expire --remote production | |
2) obtain url string to backup from step 1: | |
heroku pgbackups:url --app production_app_name --remote production_app_branch_name | |
3) transfer backup from production to staging app: | |
heroku pgbackups:restore DATABASE 'production_app_backup_url_string_from_step_2' --app production_app_name --app staging_app_branch_name |
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
heroku pgbackups:capture -a gsa-live --expire | |
heroku pgbackups:restore HEROKU_POSTGRESQL_GREEN -a gsa-staging `heroku pgbackups:url -a gsa-live` |
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
psql -h localhost | |
\c gsa_development; | |
REINDEX DATABASE gsa_development; | |
SELECT MAX(id) FROM taggings; | |
SELECT nextval('taggings_id_seq'); | |
SELECT setval('taggings_id_seq', (SELECT MAX(id) FROM taggings)+1); |
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
class hey | |
def hi | |
if true | |
end | |
end | |
end |
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
mate /etc/hosts | |
*add lines to hosts file / comment out to use sites* | |
dscacheutil -flushcache |
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
class CreateSearches < ActiveRecord::Migration | |
def self.up | |
ActiveRecord::Base.connection.execute <<-SQL | |
CREATE VIEW searches AS | |
SELECT authors.id AS searchable_id, authors.name AS term, | |
CAST ('Author' AS varchar) AS searchable_type | |
FROM authors | |
UNION | |
SELECT books.id AS searchable_id, books.title AS term, | |
CAST ('Book' AS varchar) AS searchable_type |
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
class Search < ActiveRecord::Base | |
# We want to reference various models | |
belongs_to :searchable, :polymorphic => true | |
# Wish we could eliminate n + 1 query problems, | |
# but we can't include polymorphic models when | |
# using scopes to search in Rails 3 | |
# default_scope :include => :searchable | |
# Search.new('query') to search for 'query' |
NewerOlder