Patch #11615
closedDatabase setup and reset
0%
Description
According to the RailsGuides: There is no need (and it is error prone) to deploy a new instance of an app by replaying the entire migration history. It is much simpler and faster to just load into the database a description of the current schema.
The patch includes the latest database schema in schema.rb and the required initial data in seeds.rb. These files allow to setup (and reset) database without running through the whole set of migrations using rake db:migrate command. Use the built-in rake db:setup and rake db:reset instead.
Note: the patch also changes svn:ignore property on db directory.
Files
Updated by Jean-Philippe Lang about 13 years ago
- Status changed from New to Closed
I can't find the ticket but it has already been discussed in the past. Maintaining schema.rb + seeds.rb in addition to the migrations set adds extra work/testing.
For example, running rake db:setup on your schema.rb with PostgreSQL raises an error. I guess it has been dumped from a MySQL database, right?
-- create_table("wiki_content_versions", {:force=>true})
NOTICE: CREATE TABLE will create implicit sequence "wiki_content_versions_id_se
q" for serial column "wiki_content_versions.id"
rake aborted!
PG::Error: ERROR: type "binary" does not exist
LINE 1: ...id" integer NOT NULL, "author_id" integer, "data" binary, "c...
^
: CREATE TABLE "wiki_content_versions" ("id" serial primary key, "wiki_content_i
d" integer NOT NULL, "page_id" integer NOT NULL, "author_id" integer, "data" bin
ary, "compression" character varying(6) DEFAULT '', "comments" character varying
(255) DEFAULT '', "updated_on" timestamp NOT NULL, "version" integer NOT NULL)
And running rake db:setup is in no way easier than running rake db:migrate IMHO.
Updated by Jean-Philippe Lang about 13 years ago
Found the discussion in the forums: .
Updated by Alexander Markelov about 13 years ago
Ooops! My mistake. I didn't check it with PostgreSQL. But any way, I think it's better to use `db:setup` instead of `db:migrate`. I will make a deeper analysis and give you my thoughts in the forums. Thanks.