All Projects → ateliware → Triplex

ateliware / Triplex

Licence: mit
Database multitenancy for Elixir applications!

Programming Languages

elixir
2628 projects

Labels

Projects that are alternatives of or similar to Triplex

commanded-ecto-projections
Read model projections for Commanded using Ecto
Stars: ✭ 68 (-73.95%)
Mutual labels:  ecto
limestone-accounts
Boilerplate Rails 5.2 multitenant SaaS application with webpack and Docker integration. Billing is scoped to accounts.
Stars: ✭ 97 (-62.84%)
Mutual labels:  saas
silky
The Silky framework is designed to help developers quickly build a microservice development framework through simple code and configuration under the .net platform.
Stars: ✭ 146 (-44.06%)
Mutual labels:  saas
Flask-Stripe-MySQL-Bootstrapped
Flask template with microservices architecture. Fully integrated with Stripe 🚀
Stars: ✭ 124 (-52.49%)
Mutual labels:  saas
open-box
Generalized and Efficient Blackbox Optimization System [SIGKDD'21].
Stars: ✭ 174 (-33.33%)
Mutual labels:  saas
ecto autoslug field
Automatically create slugs for Ecto schemas.
Stars: ✭ 138 (-47.13%)
Mutual labels:  ecto
timeoff-server
TimeOff is an application that allows companies' employees to set vacations before they begin taking their time off. Implemented in modern tech stack i.e. Node, Express, MongoDB.
Stars: ✭ 33 (-87.36%)
Mutual labels:  saas
Awesome Ecommerce Stack
💰 Popular marketing tools and add-ons used by 10,000+ of the top e-commerce stores.
Stars: ✭ 255 (-2.3%)
Mutual labels:  saas
ecto diff
Generates a data structure describing the difference between two ecto structs
Stars: ✭ 22 (-91.57%)
Mutual labels:  ecto
saasform
Add signup & payments to your SaaS in minutes.
Stars: ✭ 247 (-5.36%)
Mutual labels:  saas
AWS Stripe-SaaS-quickstart
🛍️ 🚀 AWS Software as a Service App with subscriptions using Stripe Quickstart
Stars: ✭ 30 (-88.51%)
Mutual labels:  saas
flop
Filtering, ordering and pagination for Ecto
Stars: ✭ 56 (-78.54%)
Mutual labels:  ecto
urlbox-screenshots-node
Capture website thumbnails using the urlbox.io screenshot as a service API in node
Stars: ✭ 14 (-94.64%)
Mutual labels:  saas
element-ui-saas-extend
基于ElementUI开发的SaaS业务扩展
Stars: ✭ 14 (-94.64%)
Mutual labels:  saas
steedos-app-contract
开源合同管理系统,基于华炎魔方开发,多租户,云服务
Stars: ✭ 74 (-71.65%)
Mutual labels:  saas
covid-19
COVID-19 World is yet another Project to build a Dashboard like app to showcase the data related to the COVID-19(Corona Virus).
Stars: ✭ 28 (-89.27%)
Mutual labels:  saas
play-tailwind
Play is free and open source Tailwind CSS template for - Startup, SaaS, Apps, Business and More. It comes with a high-quality design and all essential components & pages you need to launch a complete website.
Stars: ✭ 60 (-77.01%)
Mutual labels:  saas
Lamp Boot
lamp-boot 基于SpringBoot(2.3.6.RELEASE) 的前后分离的快速开发平台,其中的可配置的SaaS功能尤其闪耀, 具备RBAC功能、网关统一鉴权、Xss防跨站攻击、自动代码生成、多种存储系统、分布式事务、分布式定时任务等多个模块,支持多业务系统并行开发, 支持多服务并行开发,可以作为后端服务的开发脚手架。代码简洁,注释齐全,架构清晰,非常适合学习和企业作为基础框架使用。
Stars: ✭ 257 (-1.53%)
Mutual labels:  saas
awesome-oss-alternatives
Awesome list of open-source startup alternatives to well-known SaaS products 🚀
Stars: ✭ 3,579 (+1271.26%)
Mutual labels:  saas
one plus n detector
Elixir library to help you detect 1+n queries in applications using Ecto
Stars: ✭ 20 (-92.34%)
Mutual labels:  ecto

Triplex

Build Status Version Downloads Coverage Status Code Climate Inline docs

A simple and effective way to build multitenant applications on top of Ecto.

Documentation

Triplex leverages database data segregation techniques (such as Postgres schemas) to keep tenant-specific data separated, while allowing you to continue using the Ecto functions you are familiar with.

Quick Start

  1. Add triplex to your list of dependencies in mix.exs:
def deps do
  [
    {:triplex, "~> 1.3.0"},
  ]
end
  1. Run in your shell:
mix deps.get

Configuration

Configure the Repo you will use to execute the database commands with:

config :triplex, repo: ExampleApp.Repo

Additional configuration for MySQL

In MySQL, each tenant will have its own MySQL database. Triplex uses a table called tenants in the main Repo to keep track of the different tenants. Generate the migration that will create the table by running:

mix triplex.mysql.install

And then create the table:

mix ecto.migrate

Usage

Here is a quick overview of what you can do with triplex!

Creating, renaming and droping tenants

To create a new tenant:

Triplex.create("your_tenant")

This will create a new database schema and run your migrations—which may take a while depending on your application.

Rename a tenant:

Triplex.rename("your_tenant", "my_tenant")

This is not something you should need to do often. :-)

Delete a tenant:

Triplex.drop("my_tenant")

More information on the API can be found in documentation.

Creating tenant migrations

To create a migration to run across tenant schemas:

mix triplex.gen.migration your_migration_name

If migrating an existing project to use Triplex, you can move some or all of your existing migrations from priv/YOUR_REPO/migrations to priv/YOUR_REPO/tenant_migrations.

Triplex and Ecto will automatically add prefixes to standard migration functions. If you have custom SQL in your migrations, you will need to use the prefix function provided by Ecto. e.g.

def up do
  execute "CREATE INDEX name_trgm_index ON #{prefix()}.users USING gin (nam gin_trgm_ops);"
end

Running tenant migrations:

mix triplex.migrate

This will migrate all of your existing tenants, one by one. In the case of failure, the next run will continue from where it stopped.

Using Ecto

Your Ecto usage only needs the prefix option. Triplex provides a helper to coerce the tenant value into the proper format, e.g.:

Repo.all(User, prefix: Triplex.to_prefix("my_tenant"))
Repo.get!(User, 123, prefix: Triplex.to_prefix("my_tenant"))

Fetching the tenant with Plug

Triplex includes configurable plugs that you can use to load the current tenant in your application.

Here is an example loading the tenant from the current subdomain:

plug Triplex.SubdomainPlug, endpoint: MyApp.Endpoint

For more information, check the Triplex.Plug documentation for an overview of our plugs.

Thanks

This lib is inspired by the gem apartment, which does the same thing in Ruby on Rails world. We also give credit (and a lot of thanks) to @Dania02525 for the work on apartmentex. A lot of the work here is based on what she has done there. And also to @jeffdeville, who forked (tenantex) taking a different approach, which gave us additional ideas.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].