/db/migrate/001_create_hashar_schema.rb
Ruby | 47 lines | 18 code | 2 blank | 27 comment | 0 complexity | 65d82523716724fda7255adef41bff28 MD5 | raw file
- #
- # 001_create_hashar_schema.rb
- # https://bitbucket.org/torresj/hashar-deep
- # Licensed under the terms of the MIT License, as specified below.
- #
- # Copyright (c) 2012 Jeremy Torres, https://bitbucket.org/torresj/hashar-deep
- #
- # Permission is hereby granted, free of charge, to any person obtaining
- # a copy of this software and associated documentation files (the
- # "Software"), to deal in the Software without restriction, including
- # without limitation the rights to use, copy, modify, merge, publish,
- # distribute, sublicense, and/or sell copies of the Software, and to
- # permit persons to whom the Software is furnished to do so, subject to
- # the following conditions:
- #
- # The above copyright notice and this permission notice shall be
- # included in all copies or substantial portions of the Software.
- #
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- #
- # Active record for the Hashar Schema.
- class CreateHasharSchema < ActiveRecord::Migration
- def self.up
- create_table :hashar_files do |t|
- t.string :file_name, :null => false
- t.string :file_hash, :null => false
- t.datetime :processed_at, :null => false
- t.datetime :created_at, :null => false
- t.datetime :updated_at, :null => false
- end
- add_index(:hashar_files, :file_name)
- add_index(:hashar_files, :file_hash)
- end
- def self.down
- drop_table :hashar_files
- remove_index(:hashar_files, :file_name)
- remove_index(:hashar_files, :file_hash)
- end
- end