<commit_before># encoding: utf-8
module MagicRecipes
  # = Postgresql - Deploy-Recipes
  # 
  # Some simple recipes for PostgreSQL
  # 
  # [Tasks:]
  #   :install                      # => Install the latest stable release of PostgreSQL.
  # 
  #   :create_database              # => Create database and user for this application.
  # 
  #   :setup                        # => Generate the database.yml configuration file.
  # 
  #   :symlink                      # => Symlink the database.yml file into latest release
  # 
  #   :kill_postgres_connections    # => kill pgsql users so database can be dropped
  # 
  #   :drop_public_shema            # => drop public shema so db is empty and not dropped
  # 
  #   :create_user                  # => Create a postgres-user for this application.
  # 
  #   :drop_user                    # => Drop the postgres-user for this application.
  # 
  #   :create_db                    # => Create only a database for this application.
  # 
  #   :drop_database                # => Drop the postgres-database for this application.
  # 
  # [Callbacks:]
  #   after "deploy:install", "postgresql:install"
  # 
  #   after "deploy:setup", "postgresql:create_database"
  # 
  #   after "deploy:setup", "postgresql:setup"
  # 
  #   after "deploy:finalize_update", "postgresql:symlink"
  # 
  module Postgresql
    def self.load_into(configuration)
      configuration.load do
        
        # code is taken from railscast #337
        
        set_default(:postgresql_host, "localhost")
        set_default(:postgresql_user) { application }
        set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
        set_default(:postgresql_database) { "#{application}_#{rails_env}" }
        set_default(:postgresql_pool, 5)
        
        namespace :postgresql do
          desc "Install the latest stable release of PostgreSQL."
          task :install, roles: :db, only: {primary: true} do
            run "#{sudo} add-apt-repository ppa:pitti/postgresql"
            run "#{sudo} apt-get -y update"
            run "#{sudo} apt-get -y install postgresql libpq-dev"
            # add constrib for hstore extension
            run "#{sudo} apt-get -y install postgresql-contrib-9.1"
          end
          after "deploy:install", "postgresql:install"
          
          desc "Create a database and user for this application."
          task :create_database, roles: :db, only: {primary: true} do
            # make a superuser .. to be able to install extensions like hstore
            run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{<PASSWORD>}';"}
            #run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
            run %Q{#{sudo} -u postgres psql -c "CREATE DATABASE #{postgresql_database} WITH OWNER #{postgresql_user};"}
          end
          after "deploy:setup", "postgresql:create_database"
          
          desc "Create a postgres-user for this application."
          task :create_user, roles: :db, only: {primary: true} do
            # make a superuser .. to be able to install extensions like hstore
            run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{<PASSWORD>}';"}
          end
          
          desc "Drop the postgres-user for this application."
          task :drop_user, roles: :db, only: {primary: true} do<commit_msg>add new postgres apt repository<commit_after># encoding: utf-8
module MagicRecipes
  # = Postgresql - Deploy-Recipes
  # 
  # Some simple recipes for PostgreSQL
  # 
  # [Tasks:]
  #   :install                      # => Install the latest stable release of PostgreSQL.
  # 
  #   :create_database              # => Create database and user for this application.
  # 
  #   :setup                        # => Generate the database.yml configuration file.
  # 
  #   :symlink                      # => Symlink the database.yml file into latest release
  # 
  #   :kill_postgres_connections    # => kill pgsql users so database can be dropped
  # 
  #   :drop_public_shema            # => drop public shema so db is empty and not dropped
  # 
  #   :create_user                  # => Create a postgres-user for this application.
  # 
  #   :drop_user                    # => Drop the postgres-user for this application.
  # 
  #   :create_db                    # => Create only a database for this application.
  # 
  #   :drop_database                # => Drop the postgres-database for this application.
  # 
  # [Callbacks:]
  #   after "deploy:install", "postgresql:install"
  # 
  #   after "deploy:setup", "postgresql:create_database"
  # 
  #   after "deploy:setup", "postgresql:setup"
  # 
  #   after "deploy:finalize_update", "postgresql:symlink"
  # 
  module Postgresql
    def self.load_into(configuration)
      configuration.load do
        
        # code is taken from railscast #337
        
        set_default(:postgresql_host, "localhost")
        set_default(:postgresql_user) { application }
        set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
        set_default(:postgresql_database) { "#{application}_#{rails_env}" }
        set_default(:postgresql_pool, 5)
        
        namespace :postgresql do
          desc "Install the latest stable release of PostgreSQL."
          task :install, roles: :db, only: {primary: true} do
            run "#{sudo} wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -"
            run "#{sudo} apt-get -y update"
            run "#{sudo} apt-get -y install postgresql"
            # add constrib for hstore extension
            run "#{sudo} apt-get -y install postgresql-contrib"
          end
          after "deploy:install", "postgresql:install"
          
          desc "Create a database and user for this application."
          task :create_database, roles: :db, only: {primary: true} do
            # make a superuser .. to be able to install extensions like hstore
            run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{<PASSWORD>_password}';"}
            #run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
            run %Q{#{sudo} -u postgres psql -c "CREATE DATABASE #{postgresql_database} WITH OWNER #{postgresql_user};"}
          end
          after "deploy:setup", "postgresql:create_database"
          
          desc "Create a postgres-user for this application."
          task :create_user, roles: :db, only: {primary: true} do
            # make a superuser .. to be able to install extensions like hstore
            run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{<PASSWORD>}';"}
          end
          
          desc "Drop the postgres-user for this application."
          task :drop_user, roles: :db, only: {primary: true} do
{'fraction_non_alphanumeric': 0.10062543432939541, 'fraction_numerical': 0.0019457956914523975, 'mean_word_length': 2.2664548343168405, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '948226', 'n_tokens_mistral': 2202, 'n_tokens_neox': 2085, 'n_words': 627}