0

I'm using tinytds to connect to a ms-sqlserver database. I've noticed that db:migrate will work as long as there isn't a table already in my database. Once I try to make changes to an object and replicate to the database using db:migrate I get the error below.

TinyTds::Error: There is already an object named 'apples' in the database.: CREATE TABLE [apples] ([id] int NOT NULL IDENTITY(1,1) PRIMARY KEY, [color] nvarchar(50), [price] nvarchar(50), [created_at] datetime NOT NULL, [updated_at] datetime NOT NULL) /var/lib/gems/1.9.1/gems/activerecord-sqlserver-adapter-3.2.10/lib/active_record/connection_adapters/sqlserver/database_statements.rb:360:in `do'

I'm not sure if the problem is that my database is incorrectly configured or that my rails project is. If anyone could provide any guidance I would greatly appreciate it! Thanks!

daveomcd
  • 6,367
  • 14
  • 83
  • 137
  • Does the user in database.yml have DROP privileges? – muttonlamb Jun 01 '13 at 14:00
  • I'm not exactly sure where to check that other than the user has the following membership roles, `'db_accessadmin','db_backupoperator','db_datareader','db_datawriter','db_ddladmin','db_owner','db_securityadmin'` – daveomcd Jun 01 '13 at 14:11
  • Did you check your schema_migrations table to see of the migration numbers are updated properly? – usha Jun 01 '13 at 14:21
  • @Vimsha, there's six rows in the table earlier. Not sure how to check if they're correct or not. – daveomcd Jun 01 '13 at 14:38
  • As far as i know, it should just have one number. The last migration that was run. That's how it decides which migrations were already run. – usha Jun 01 '13 at 14:40
  • @Vimsha, so I deleted the records except for the latest one but now I'm getting a similar message for another table so I'm guessing it needs them all. – daveomcd Jun 01 '13 at 14:58

1 Answers1

0

This really isn't a fix, but just wanted to follow up with the solution that I went with. I ended up backing up my data and deleting the tables and rerunning rake db:migrate and then reinserted the data through sql server.

daveomcd
  • 6,367
  • 14
  • 83
  • 137