Created
August 17, 2017 10:50
-
-
Save Evshved/a85efe182df64e11f91c8a55f4687ed0 to your computer and use it in GitHub Desktop.
migration.rb
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
| class CreateSites < ActiveRecord::Migration | |
| def up | |
| create_table :related_sites, :options=>"DEFAULT CHARSET=utf8" do |t| | |
| t.string :title, null: false, default: '' | |
| t.string :domain_name, null: false, default: '' | |
| t.string :hash_domain, null: false, default: '' | |
| domain_name varchar(255) NOT NULL DEFAULT '', | |
| hash_domain varchar(32) CHARACTER SET latin1 NOT NULL DEFAULT '', | |
| description mediumtext, | |
| status tinyint(2) NOT NULL DEFAULT '0', | |
| last_parsed_at date NOT NULL DEFAULT '0000-00-00', | |
| created_at date NOT NULL DEFAULT '0000-00-00', | |
| updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| owner_type tinyint(1) NOT NULL DEFAULT '0', | |
| last_get_access date NOT NULL DEFAULT '0000-00-00', | |
| site_type tinyint(2) NOT NULL DEFAULT '0', | |
| is_english tinyint(2) NOT NULL DEFAULT '-1', | |
| visibility_type tinyint(2) NOT NULL DEFAULT '0', | |
| bad_rank tinyint(2) NOT NULL DEFAULT '0', | |
| related_status tinyint(4) NOT NULL DEFAULT '0', | |
| related_parsed_at date NOT NULL DEFAULT '0000-00-00', | |
| competing_rank tinyint(4) NOT NULL DEFAULT '-1', | |
| end | |
| end | |
| def down | |
| end | |
| end | |
| class CreateRelatedSites < ActiveRecord::Migration | |
| def up | |
| create_table :related_sites, :options=>"DEFAULT CHARSET=utf8" do |t| | |
| t.references :site, :null=>false | |
| t.references :related, :null=>false | |
| t.column :weight, "int(11) NOT NULL DEFAULT '0'" | |
| t.column :is_description, "tinyint(4) NOT NULL DEFAULT '-1'" | |
| t.column :keywords_count, "tinyint(4) NOT NULL DEFAULT '-1'" | |
| t.column :matches_count, "tinyint(4) NOT NULL DEFAULT '-1'" | |
| t.column :is_english, "tinyint(4) NOT NULL DEFAULT '0'" | |
| t.column :site_bad_rank, "tinyint(4) NOT NULL DEFAULT '0'" | |
| t.column :related_bad_rank, "tinyint(4) NOT NULL DEFAULT '0'" | |
| t.date :created_at, :null=>false, :default=>'0000-00-00' | |
| end | |
| add_index :related_sites, [:site_id, :related_id], :unique=>true | |
| add_index :related_sites, [:site_id, :related_bad_rank, :weight, :created_at], :name=>'related_index' | |
| end | |
| def down | |
| drop_table :related_sites | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment