Pergunta

Imagine a program which operates large hierarhical datasets. The program stores each new such dataset in a dedicated table. The table is created accordingly to what data types the dataset has in it. Well, nothing very unusual. This is a trivial situation. But how do I make this kind of arrangements in Play 2.0, where the evolution paradigm rules? I just cannot start thinking of it.

UPDATE

It turned out, there is no simple way. Ok. The round way.

Is it possible to:

1) Make the program write the evolutions files itself and apply them automatically? Will it cause some distortion with Play's philosophy?

2) Use another DB system in a separate thread and do not use the Play's innate databsae functionality? Would that hurt much?

UPDATE 2

I am reading though MongoDB Casbah documentation and I like it a lot. I am planning to use this with my Play application. Is there any contra-evidence for using MongoDB via Casbah with Play?

Foi útil?

Solução 2

Well, after some more experiments, I have concluded to use MongoDB (actually, I had to choose from a wide variety of document-oriented DBMSs, and decided to start with MongoDB). I have established a MongoDB server, incorporated it's Java driver, Casbah (the driver's Scala-wrapper) and all the necessary dependencies into my project, and all works fine. No need for SQL or the evolutions paradigm, whatsoever.

And I am not using any parts of Play that work with database (the config file, anorm, and what's else is there), just ignoring that, and doing all Mongo.

All works JUST FINE!

Outras dicas

Thst's good question. And there's no brilliant answer, unfortunately.

Generally evolutions are good and are desired when you work in group. In such case you should switch to manual evolutions (not these generated by Ebean, they are dangerous to your data in current state) and just put your initial DDL as big as possible with create statements.

In next evolutions you can create new tables or alter existing, but for god's sake do not try to create existing table :)

Other approach I was (or still) thinking about is using Ebean's auto-generated DDLs (which always assumes that your DB is empty) to generate differential schemas with some SQL schema migration tools (ie mybatis) but this is unfortunately additional effort required.

The last thing I sometimes use when I'm not sure about correct evolution syntax is small test-field app where you can add similar models and watch how Ebean's plugin will threat them. Unfortunately even this solution won't create proper alters, but it's better then testing on main app.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top