Skip to content

Migration

Don Peter edited this page Oct 1, 2017 · 2 revisions

Migrate from an existing ORM / sqlite database to ONAM

For migration, you will have the ability to suggest database name, table names and column names,

To specify database name, You may use the annotation @DB

@DB(name = "blog_db", tables = {Post.class,Comment.class,User.class}, version = 1)

For table name, use
@Table(name="your_table_name")

   @Table(name = "post")
   public class Post extends Entity {
   }

For column name, use
@Column(name="column_name")

    @Column(name = "created_at")
    public long getCreatedAt() {
        return created_at;
    }

The column name needs to be provided for getter functions.

For foreign key in a ManyToOne mapping, you may specify column name as follows

    @ManyToOne
    @Column(name = "post_id")
    public Post getPost() {
        return fetch(this.post,new Post(){});
    }
Clone this wiki locally