alpas v0.15.0 Release Notes

Release Date: 2020-02-18 // about 4 years ago
  • ๐Ÿš€ This release brings even more exciting features and improvements to Alpas. Here are the highlights:

    ๐Ÿฑ ๐ŸŽ‰ New Features

    โœ”๏ธ Resourceful Routes

    You can create a resourceful routes for all the CRUD operations by using resources() method:
    resources<PostController>("posts").name("posts")

    โœ”๏ธ Auto Port Selection

    ๐Ÿ“„ In dev mode Alpas automatically selects the next port if the selected port is in use already. Docs.

    โœ”๏ธ Ozone Extensions

    โšก๏ธ Few useful methods and conventions are added in Ozone such as findOrCreate(attrs), findOne(attrs), findMany(), update(attrs), reference() etc. Docs.

    โœ”๏ธ Column Binding Conventions

    โšก๏ธ Also added are four new column bindings - createdAt(), updatedAt(), increments(), bigIncrements().
    ๐Ÿ“„ Docs.

    This means instead of this:

    val id by bigInt("id").autoIncrement().unsigned().primaryKey().bindTo{ it.id }val createdAt by timestamp("created\_at").nullable().useCurrent().bindTo { it.createdAt }val updatedAt by timestamp("updated\_at").nullable().useCurrent().bindTo { it.updatedAt }
    

    You can do this:

    val id by bigIncrements()val createdAt by createdAt()val updatedAt by updatedAt()
    

    โœ”๏ธ Routes reloading without re-running the app

    ๐ŸŽ In dev mode, routes are now reloaded without restarting the app. For performance reason this is disabled in the prod mode.

    โœ”๏ธ Run migrations using a name property

    This allows to run migrations even from a fat jar. Very helpful in production.

    โœ”๏ธ Added basic table modification support

    You can now addColumn() and dropColumn()

    โœ”๏ธ Reference Constraint

    You can now add a reference constraint on a column:

    val userId by long("user\_id").belongsTo(Users) { it.user }.unsigned().reference { onDeleteCascade() }
    

    ๐Ÿฑ ๐Ÿ’„ Improvements

    โšก๏ธ ๐Ÿ˜€ Assets handling is more optimized.

    ๐Ÿ‘€ ๐Ÿ˜€ You can seed a database with database refresh by using --seed flag.

    ๐Ÿฑ ๐Ÿ˜€ Improved strong typing while overriding an entity's properties in an entity factory.

    val user = from(UserFactory) { it.name to "Jane M. Doe" it.email to "[email protected]"}
    

    ๐Ÿฑ ๐Ÿ’” Breaking Changes

    ๐Ÿš€ There are few but significant breaking changes in this release:

    ๐Ÿคฆ๐Ÿฝโ€โ™‚๏ธ Entity has been renamed to OzoneEntity and MigratingTable has been renamed to OzoneTable:

    // Before: interface User : Entity\<User\>// Now:interface User : OzoneEntity\<User\> { // ...// Before: companion object : Entity.Factory\<User\>// Now:companion object : OzoneEntity.Of\<User\>() }// Before: object Users : MigratingTable\<User\>// Now:object Users : OzoneTable\<User\>("users") { // ...}
    

    ๐Ÿคฆ๐Ÿฝโ€โ™‚๏ธ EntityFactory now takes two parameters instead of one:

    // Before: class UserFactory() : EntityFactory\<User\>()// Now:class UserFactory() : EntityFactory\<User, Users\>() { // ...}
    

    ๐Ÿคฆ๐Ÿฝโ€โ™‚๏ธ Methods Renamed:

    • onlyParams() method has been renamed to params()
    • paramAsString() method is now stringParam()
    • paramAsInt() is now intParam()
    • paramAsLong() is now longParam()
    • paramAsBool() is now boolParam()