Christian R. Garner
2006-May-02 16:32 UTC
[Rails] Tests just deleted my production Database!!!
Sorry, in my haste I forgot to modify the subject. 5/2/06, "Christian R. Garner" <olus@digitalapathy.net>wrote:> > All assumptions aside, "rectest" and "salt" are usernames not > databases/schemas according to the pasted config. If they were in fact > different databases/schemas, this problem could never have happened. > While > different database brands may have tricks for ways to handle users and > what > they perceive as a database/schema, the fact remains that if 2 literally > separate databases had been used this thread wouldn''t exist. > > -Christian > > On 5/2/06, "Glenn Stauffer" <alaxsxaq@gmail> wrote: > > In his database.yml file, development and production use the same > > database schema (salt); test uses a different schema (rectest). > > > > Now, if rectest did not have its own set of tables, but instead had > > full privileges (insert/update/delete) to the production tables with > > public synonyms hiding the fact that the production tables are in a > > different schema (making them accessible without the schema prefix), > > that might explain why rake would wipe the salt > > (production/development) tables when logged in as rectest. > > > > Glenn > > > > On 5/2/06, Christian R. Garner <olus@digitalapathy.net> wrote: > > > > > > When you run your functional tests, rake wipes the "test" database > clean > > and > > > recreates it based on what is in the "development" database. Since it > > > appears you are using the same database for both, that would explain > why > > you > > > lost your data. In addition, if you omit the data needed to access > the > > > development database you will get an error like you described, because > > it''s > > > trying to read the development database to create the test database. > > > > > > Furthermore, the default database.yml file that gets created with a > new > > > rails instance has the following comment right before the "test" > > database > > > block: > > > > > > # Warning: The database defined as ''test'' will be erased and > > > # re-generated from your development database when you run ''rake''. > > > # Do not set this db to the same as development or production. > > > > > > > > > - Christian > > > > > > On 02/05/06, Jon <jonfgreg@gmail.com> wrote: > > > > > > > > Running the functional tests has deleted the data in my production > > > > database!!! please help!! Using rails 1.1.1 + Oracle. > > > > > > > > This is my database.yml file : > > > > > > > > development: > > > > adapter: oci > > > > host: "V2:1521/TIM" > > > > username: salt > > > > password: oracle1 > > > > > > > > test: > > > > adapter: oci > > > > host: "V2:1521/TIM" > > > > username: rectest > > > > password: oracletest > > > > > > > > production: > > > > adapter: oci > > > > host: "V2:1521/TIM" > > > > username: salt > > > > password: oracle1 > > > > > > > > > > > > How did it happen. It seems impossible > > >
In Oracle, each schema is owned by one username and, in many systems, username is essentially equal to schema. That isn''t necessarily the case and multiple usernames can share a schema as though it were their own through granting of explicit permissions and creation of object synonyms - I would suggest that this is what tripped up the person who ran into the problem behind this thread. If you are seeking isolation between Oracle database schemas to enable the production/test/development environment, all you have to do is ensure that you replicate the application schema in each of the accounts you wish to use for development, test, and production. No need to incur the overhead of separate database instances. --Glenn On 5/2/06, Christian R. Garner <olus@digitalapathy.net> wrote:> Sorry, in my haste I forgot to modify the subject. > > 5/2/06, "Christian R. Garner" <olus@digitalapathy.net>wrote: > > > > All assumptions aside, "rectest" and "salt" are usernames not > > databases/schemas according to the pasted config. If they were in fact > > different databases/schemas, this problem could never have happened. > > While > > different database brands may have tricks for ways to handle users and > > what > > they perceive as a database/schema, the fact remains that if 2 literally > > separate databases had been used this thread wouldn''t exist. > > > > -Christian > > > > On 5/2/06, "Glenn Stauffer" <alaxsxaq@gmail> wrote: > > > In his database.yml file, development and production use the same > > > database schema (salt); test uses a different schema (rectest). > > > > > > Now, if rectest did not have its own set of tables, but instead had > > > full privileges (insert/update/delete) to the production tables with > > > public synonyms hiding the fact that the production tables are in a > > > different schema (making them accessible without the schema prefix), > > > that might explain why rake would wipe the salt > > > (production/development) tables when logged in as rectest. > > > > > > Glenn > > > > > > On 5/2/06, Christian R. Garner <olus@digitalapathy.net> wrote: > > > > > > > > When you run your functional tests, rake wipes the "test" database > > clean > > > and > > > > recreates it based on what is in the "development" database. Since it > > > > appears you are using the same database for both, that would explain > > why > > > you > > > > lost your data. In addition, if you omit the data needed to access > > the > > > > development database you will get an error like you described, because > > > it''s > > > > trying to read the development database to create the test database. > > > > > > > > Furthermore, the default database.yml file that gets created with a > > new > > > > rails instance has the following comment right before the "test" > > > database > > > > block: > > > > > > > > # Warning: The database defined as ''test'' will be erased and > > > > # re-generated from your development database when you run ''rake''. > > > > # Do not set this db to the same as development or production. > > > > > > > > > > > > - Christian > > > > > > > > On 02/05/06, Jon <jonfgreg@gmail.com> wrote: > > > > > > > > > > Running the functional tests has deleted the data in my production > > > > > database!!! please help!! Using rails 1.1.1 + Oracle. > > > > > > > > > > This is my database.yml file : > > > > > > > > > > development: > > > > > adapter: oci > > > > > host: "V2:1521/TIM" > > > > > username: salt > > > > > password: oracle1 > > > > > > > > > > test: > > > > > adapter: oci > > > > > host: "V2:1521/TIM" > > > > > username: rectest > > > > > password: oracletest > > > > > > > > > > production: > > > > > adapter: oci > > > > > host: "V2:1521/TIM" > > > > > username: salt > > > > > password: oracle1 > > > > > > > > > > > > > > > How did it happen. It seems impossible > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >