*rails uses SQLite for database by default 

*Built-in command-line DB viewer 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

*Self-contained,server-less,zero-configuration,transactional, relational SQL database.

 

Database Setup: config/database.yml 

rails db - SQLite console mode 

Turn headers on and column mode: 

*.headers on 

*mode columns

.exit 退出SQLite console

 

Migrations: 

*Migration are just Ruby classes that get translated into DB speak

*Table in the DB keeps track of which migration was applied last

Ruby classes that extend ActiveRecord::Migration 

File name need to start with a timestamp

apply all the migration:  rake db:migrate 

Migration code maintains a table called schema_migrations table with one column called version.

Once the migration is applied - its version(timestamp) goes into the schema_migrations table.

database indenpence: different database adopter.

 

Exta Column Options: 

null: true    null:false 

 limit: size   

default: value  

precision: value (total number of digits stored)

scale: value

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄