fix migrations and create database

This commit is contained in:
Ilion Beyst 2015-09-08 11:44:07 +02:00
parent f96ddba717
commit cb05d1d742
5 changed files with 60 additions and 47 deletions

View file

@ -1,6 +1,3 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
# Include default devise modules. Others available are: devise :timeoutable, :omniauthable, :omniauth_providers => [:zeuswpi]
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end end

View file

@ -1,45 +1,11 @@
class DeviseCreateUsers < ActiveRecord::Migration class DeviseCreateUsers < ActiveRecord::Migration
def change def change
create_table(:users) do |t| create_table(:users) do |t|
## Database authenticatable t.string :name, index: true, unique: true
t.string :email, null: false, default: "" t.integer :balance, null: false, default: 0, index: true
t.string :encrypted_password, null: false, default: "" t.boolean :penning, null: false, default: false
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.string :name
t.integer :balance
t.boolean :penning
t.timestamps null: false t.timestamps null: false
end end
add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true
end end
end end

View file

@ -1,10 +1,10 @@
class CreateTransactions < ActiveRecord::Migration class CreateTransactions < ActiveRecord::Migration
def change def change
create_table :transactions do |t| create_table :transactions do |t|
t.references :debtor, index: true, foreign_key: true t.references :debtor, index: true, foreign_key: true, null: false
t.references :creditor, index: true, foreign_key: true t.references :creditor, index: true, foreign_key: true, null: false
t.integer :amount t.integer :amount, null: false, default: 0
t.string :origin t.string :origin, null: false
t.string :message t.string :message
t.timestamps null: false t.timestamps null: false

View file

@ -1,8 +1,8 @@
class CreateClients < ActiveRecord::Migration class CreateClients < ActiveRecord::Migration
def change def change
create_table :clients do |t| create_table :clients do |t|
t.string :name t.string :name, null: false, index: true, unique: true
t.string :key t.string :key, null: false, index: true, unique: true
t.timestamps null: false t.timestamps null: false
end end

50
db/schema.rb Normal file
View file

@ -0,0 +1,50 @@
# 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: 20150908092731) do
create_table "clients", force: :cascade do |t|
t.string "name", null: false
t.string "key", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "clients", ["key"], name: "index_clients_on_key"
add_index "clients", ["name"], name: "index_clients_on_name"
create_table "transactions", force: :cascade do |t|
t.integer "debtor_id", null: false
t.integer "creditor_id", null: false
t.integer "amount", default: 0, null: false
t.string "origin", null: false
t.string "message"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "transactions", ["creditor_id"], name: "index_transactions_on_creditor_id"
add_index "transactions", ["debtor_id"], name: "index_transactions_on_debtor_id"
create_table "users", force: :cascade do |t|
t.string "name"
t.integer "balance", default: 0, null: false
t.boolean "penning", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "users", ["balance"], name: "index_users_on_balance"
add_index "users", ["name"], name: "index_users_on_name"
end