Add initial models and corresponding test files

This commit is contained in:
Martin Lensment 2014-06-16 17:21:01 +03:00
parent bca4470643
commit 542ea5101e
28 changed files with 548 additions and 8 deletions

View file

@ -0,0 +1,125 @@
class Init < ActiveRecord::Migration
def change
create_table :domains do |t|
t.string :name #ascii, utf8 will be converted on the fly
t.integer :registrar_id #registripidaja
t.datetime :registered_at
t.string :status
t.datetime :valid_from
t.datetime :valid_to
t.integer :owner_contact_id
t.integer :admin_contact_id
t.integer :technical_contact_id
t.integer :ns_set_id
t.string :auth_info
#t.integer :keyset_id #dnssec
t.timestamps
end
# this will be a huge table?
create_table :contacts do |t|
t.string :code #CID:STRING:OID
t.string :name
t.string :type #organisation / juridical / citizen #rails specific variable
t.string :reg_no #identity code or registration number for organisation
# can a person have one or more of these contacts?
t.string :phone
t.string :email
t.string :fax
t.timestamps
end
create_table :addresses do |t| #needs a better name?
t.integer :contact_id
t.integer :country_id
t.string :city
t.string :address #Street + house + apartment #needs a better name
t.string :zip
t.timestamps
end
create_table :country_id do |t|
t.string :iso
t.string :name
t.timestamps
end
create_table :registrars do |t|
t.string :name
t.string :reg_no
t.string :vat_no
t.string :address
t.integer :country_id
t.string :billing_address
t.timestamps
end
#legal documents
# create_table :documents do |t|
# t.integer :domain_id
# t.string :name
# t.status :document_type #if this is registration document or deletion document
# t.timestamps
# end
create_table :ns_sets do |t|
t.string :code #NSSID:STRING:OID
t.integer :registrar_id
t.string :auth_info #password for transferring between registrants
t.string :report_level
#t.integer :technical_contact_id # reference to technical contact -
#does each ns_set have spearate technical contacts or can the contacts be inherited from the registrar?
t.timestamps
end
create_table :nameservers_ns_sets do |t|
t.integer :nameserver_id
t.integer :ns_set_id
end
create_table :nameservers do |t|
t.string :name
t.string :ip
t.integer :ns_set_id
t.timestamps
end
#devise for login
#cancan for securing
#what to do with API users?
create_table :users do |t|
t.string :username
t.string :password
t.integer :role_id #can user have more than one role?
t.timestamps
end
create_table :roles do |t|
t.string :name
t.timestamps
end
create_table :rights_roles do |t|
t.integer :right_id
t.integer :role_id
end
create_table :rights do |t|
t.string :code #LOG_IN, SEE_DOMAINS, etc
t.timestamps
end
end
end

122
db/schema.rb Normal file
View file

@ -0,0 +1,122 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140616073945) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "addresses", force: true do |t|
t.integer "contact_id"
t.integer "country_id"
t.string "city"
t.string "address"
t.string "zip"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "contacts", force: true do |t|
t.string "code"
t.string "name"
t.string "type"
t.string "reg_no"
t.string "phone"
t.string "email"
t.string "fax"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "country_id", force: true do |t|
t.string "iso"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "domains", force: true do |t|
t.string "name"
t.integer "registrar_id"
t.datetime "registered_at"
t.string "status"
t.datetime "valid_from"
t.datetime "valid_to"
t.integer "owner_contact_id"
t.integer "admin_contact_id"
t.integer "technical_contact_id"
t.integer "ns_set_id"
t.string "auth_info"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "nameservers", force: true do |t|
t.string "name"
t.string "ip"
t.integer "ns_set_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "nameservers_ns_sets", force: true do |t|
t.integer "nameserver_id"
t.integer "ns_set_id"
end
create_table "ns_sets", force: true do |t|
t.string "code"
t.integer "registrar_id"
t.string "auth_info"
t.string "report_level"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "registrars", force: true do |t|
t.string "name"
t.string "reg_no"
t.string "vat_no"
t.string "address"
t.integer "country_id"
t.string "billing_address"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "rights", force: true do |t|
t.string "code"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "rights_roles", force: true do |t|
t.integer "right_id"
t.integer "role_id"
end
create_table "roles", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "users", force: true do |t|
t.string "username"
t.string "password"
t.integer "role_id"
t.datetime "created_at"
t.datetime "updated_at"
end
end