束缚:数据库约束使ActiveRecord变得容易

时间:2021-02-02 04:08:50
【文件属性】:
文件名称:束缚:数据库约束使ActiveRecord变得容易
文件大小:44KB
文件格式:ZIP
更新时间:2021-02-02 04:08:50
ruby rails activerecord postgres library in绳 是一件好事。 在数据库级别(而不是在应用程序级别)限制应用程序所允许的值,是一种确保数据保持健全的更可靠的方法。 不幸的是,ActiveRecord不鼓励(甚至不允许)使用数据库完整性而不求助于手工SQL。 Rein(发音为“ rain”)为ActiveRecord迁移添加了一些方法,因此您可以轻松地驯服数据库中的数据。 DSL中的所有方法都是自动可逆的,因此您可以利用可逆的Rails迁移。 目录 入门 安装gem: > gem install rein 为您的迁移添加约束: class CreateAuthorsTable < ActiveRecord :: Migration def change create_table :authors do | t | t . string :name , null : false end # An author must have a name. add_presence_constraint :authors , :name end end 约束类型 概要 下表总结了R
【文件预览】:
rein-master
----gemfiles()
--------activerecord_6.gemfile(122B)
--------activerecord_4.gemfile.lock(2KB)
--------activerecord_5_2.gemfile.lock(2KB)
--------activerecord_6.gemfile.lock(2KB)
--------activerecord_5.gemfile(122B)
--------activerecord_5_2.gemfile(122B)
--------activerecord_4.gemfile(122B)
--------activerecord_5.gemfile.lock(2KB)
----rein.gemspec(1KB)
----lib()
--------rein()
--------rein.rb(1KB)
----Gemfile(88B)
----spec()
--------integration()
--------migrations()
--------rein()
--------spec_helper.rb(2KB)
--------support()
----Rakefile(212B)
----.travis.yml(314B)
----LICENSE.md(1KB)
----README.md(20KB)
----.rubocop.yml(596B)
----Makefile(216B)
----Appraisals(269B)
----.rspec(31B)
----.editorconfig(178B)
----.yardopts(18B)
----.gitignore(35B)
----CHANGELOG.md(1KB)

网友评论