Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Thursday, December 31, 2009

MySQL Table Exists (1050) but Doesn't Exist (1051)

Ran into an interesting issue this morning:


mysql> drop table RELATIONSHIP_TYPE;
ERROR 1051 (42S02): Unknown table 'relationship_type'


Which wouldn't be that weird except for:

mysql> CREATE TABLE `RELATIONSHIP_TYPE` (`relationshipTypeId` INT UNSIGNED AUTO_INCREMENT NOT NULL, `name` VARCHAR(10) NOT NULL, `code` VARCHAR(2) NOT NULL, CONSTRAINT `PK_RELATIONSHIP_TYPE` PRIMARY KEY (`relationshipTypeId`)) ENGINE INNODB;
ERROR 1050 (42S01): Table 'relationship_type' already exists


After a fair amount of Google searching, I finally found an answer that implied I should try this:

$ mysqladmin flush-tables


Which seems to have solved the problem. I'm posting this in the hopes that the next person will have an easier time finding the answer.

Friday, July 13, 2007

Ruby on Rails continuously integrated with Bamboo

Since I tripped over a few things setting up Bamboo for Rails, I thought it would be good to share my approach. After my last post, someone from Atlassian thought that would be a good idea as well, so, what the heck.

Creating a Simple Rails Project


In order to demonstrate configuring a project on Bamboo, it's easiest for me just to create a simple rails project, with a model and scaffold. This'll come with tests, albeit useless ones. But if you wanted a tutorial on how to use Rails, you've come to the wrong place.


geoffrey@paraietta:~/projects$ rails bamboo-rails
create
create app/controllers
create app/helpers
create app/models
...
create log/production.log
create log/development.log
create log/test.log
geoffrey@paraietta:~/projects$ cd bamboo-rails/
geoffrey@paraietta:~/projects/bamboo-rails$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database `bamboo-rails_development`;
Query OK, 1 row affected (0.01 sec)

mysql> create database `bamboo-rails_test`;
Query OK, 1 row affected (0.00 sec)

mysql> quit
Bye
geoffrey@paraietta:~/projects/bamboo-rails$ script/generate model foo bar:string baz:string
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/foo.rb
create test/unit/foo_test.rb
create test/fixtures/foos.yml
create db/migrate
create db/migrate/001_create_foos.rb
geoffrey@paraietta:~/projects/bamboo-rails$ rake db:migrate
(in /mnt/home/geoffrey/projects/bamboo-rails)
== CreateFoos: migrating ======================================================
-- create_table(:foos)
-> 0.0040s
== CreateFoos: migrated (0.0041s) =============================================

geoffrey@paraietta:~/projects/bamboo-rails$ script/generate scaffold foo
exists app/controllers/
exists app/helpers/
create app/views/foos
...
create app/views/layouts/foos.rhtml
create public/stylesheets/scaffold.css


Add the Project to Source Control


Once the project's created, it has to be somewhere that Bamboo can reach it. The usual practice is a source control system. In this case, I'm using Subversion.

geoffrey@paraietta:~/projects$ svn import bamboo-rails http://messis/svn/spikes/bamboo-rails -m "A simple Rails/Bamboo integration project."
Adding bamboo-rails/test
Adding bamboo-rails/test/unit
Adding bamboo-rails/test/unit/foo_test.rb
...
Adding bamboo-rails/public/stylesheets
Adding bamboo-rails/public/stylesheets/scaffold.css
Adding bamboo-rails/public/favicon.ico

Committed revision 190.

Configure Bamboo for Ruby



In order to build anything in Bamboo/Ruby, you're going to want to configure a builder in Bamboo. There may be a way to use one of the existing builders, but this is what worked for me. Just add a builder for Ruby and point it to your ruby executable.

Create a Plan for your Ruby Project


You're going to want to create a Project and Plan for your Ruby project. Bamboo projects are umbrellas for related Plans:

Plans tell Bamboo what you're trying to build, where to find the source code:

They also tell Bamboo how to build what it finds:

They also tell Bamboo what to do with the results, and whom to notify, but those steps aren't unique to Rails in any way, so I'm going to leave them out. At this point, you have a project and plan defined in Bamboo, so you can check to see if it worked:
It didn't. I didn't create the database on the build server. Once I've done that:

Et Voila

You've got a basic Ruby on Rails project building in Bamboo. This is the bare minimum setup. There's a lot of things you can add from here. In my next post, I'll cover getting Bamboo to recognize your test results and calculate coverage.

Monday, June 18, 2007

MySQL - No Millisecond-Precision Date/Time

I guess I've been spoiled not doing anything particularly serious in MySQL thus far; I'm only just now discovering that it doesn't support millisecond-precision date-time datatypes directly. Fascinating.


Not a big deal most of the time, but for some precise date-comparison routines, we've used this capability before, in Oracle, and in other databases, so I'm just a little surprised.