Initial commit
This commit is contained in:
2
database/.gitignore
vendored
Normal file
2
database/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.sqlite
|
||||
*.sqlite-journal
|
||||
107
database/factories/FormFactory.php
Normal file
107
database/factories/FormFactory.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Forms\Form;
|
||||
use App\Models\Workspace;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FormFactory extends Factory
|
||||
{
|
||||
protected $model = Form::class;
|
||||
|
||||
public function forWorkspace(Workspace $workspace)
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($workspace) {
|
||||
return [
|
||||
'workspace_id' => $workspace->id,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function forDatabase(string $databaseId)
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($databaseId) {
|
||||
return [
|
||||
'database_id' => $databaseId,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function withProperties(array $properties)
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($properties) {
|
||||
return [
|
||||
'properties' => $properties,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function createdBy(User $user)
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($user) {
|
||||
return [
|
||||
'creator_id' => $user->id,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'title' => $this->faker->text(30),
|
||||
'description' => $this->faker->randomHtml(2),
|
||||
'notifies' => false,
|
||||
'send_submission_confirmation' => false,
|
||||
'webhook_url' => null,
|
||||
'theme' => $this->faker->randomElement(Form::THEMES),
|
||||
'width' => $this->faker->randomElement(Form::WIDTHS),
|
||||
'dark_mode' => $this->faker->randomElement(Form::DARK_MODE_VALUES),
|
||||
'color' => '#3B82F6',
|
||||
'hide_title' => false,
|
||||
'no_branding' => false,
|
||||
'uppercase_labels' => true,
|
||||
'transparent_background' => false,
|
||||
'submit_button_text' => 'Submit',
|
||||
're_fillable' => false,
|
||||
're_fill_button_text' => 'Fill Again',
|
||||
'submitted_text' => '<p>Amazing, we saved your answers. Thank you for your time and have a great day!</p>',
|
||||
'notification_sender' => 'OpenForm',
|
||||
'notification_subject' => 'We saved your answers',
|
||||
'notification_body' => 'Hello there 👋 <br>This is a confirmation that your submission was successfully saved.',
|
||||
'notifications_include_submission' => true,
|
||||
'use_captcha' => false,
|
||||
'can_be_indexed' => true,
|
||||
'password' => false,
|
||||
'tags' => []
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a Notion database list of properties, format them as the front-end does:
|
||||
* - Adds id
|
||||
* - Adds placeholder, prefill, help
|
||||
* - Adds notion_name
|
||||
* @param $properties
|
||||
* @return array
|
||||
*/
|
||||
public static function formatProperties($properties): array
|
||||
{
|
||||
return collect($properties)->map(function ($property) {
|
||||
return array_merge($property, [
|
||||
'id' => Str::uuid(),
|
||||
'placeholder' => $property['name'],
|
||||
'prefill' => null,
|
||||
'help' => 'Please fill this input',
|
||||
'notion_name' => $property['name'],
|
||||
]);
|
||||
})->toArray();
|
||||
}
|
||||
}
|
||||
34
database/factories/UserFactory.php
Normal file
34
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = User::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->name,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'hear_about_us' => 'google',
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
database/migrations/2014_10_12_000000_create_users_table.php
Normal file
36
database/migrations/2014_10_12_000000_create_users_table.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateOauthProvidersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('oauth_providers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('user_id')->unsigned();
|
||||
$table->string('provider');
|
||||
$table->string('provider_user_id')->index();
|
||||
$table->string('access_token')->nullable();
|
||||
$table->string('refresh_token')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('oauth_providers');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFailedJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateWorkspacesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('workspaces', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string('access_token');
|
||||
$table->string('name');
|
||||
$table->text('icon')->nullable();
|
||||
$table->foreignIdFor(\App\Models\User::class, 'user_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('workspaces');
|
||||
}
|
||||
}
|
||||
67
database/migrations/2021_05_19_140326_create_forms_table.php
Normal file
67
database/migrations/2021_05_19_140326_create_forms_table.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFormsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('forms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\App\Models\Workspace::class,'workspace_id');
|
||||
$table->string('title');
|
||||
$table->string('slug');
|
||||
$table->json('properties');
|
||||
$table->timestamps();
|
||||
$table->boolean('notifies')->default(false);
|
||||
$table->text('description')->nullable();
|
||||
$table->text('submit_button_text')->default('Submit');
|
||||
$table->boolean('re_fillable')->default(false);
|
||||
$table->text('re_fill_button_text')->default('Fill Again');
|
||||
$table->string('color')->default('#3B82F6');
|
||||
$table->boolean('uppercase_labels')->default(true);
|
||||
$table->boolean('no_branding')->default(false);
|
||||
$table->boolean('hide_title')->default(false);
|
||||
$table->text('submitted_text')->default('Amazing, we saved your answers. Thank you for your time and have a great day!');
|
||||
$table->string('dark_mode')->default('auto');
|
||||
$table->string('webhook_url')->nullable();
|
||||
$table->boolean('send_submission_confirmation')->default(false);
|
||||
$table->string('logo_picture')->nullable();
|
||||
$table->string('cover_picture')->nullable();
|
||||
$table->string('redirect_url')->nullable();
|
||||
$table->text('custom_code')->nullable();
|
||||
$table->text('notification_emails')->nullable();
|
||||
$table->string('theme')->default('default');
|
||||
$table->jsonb('database_fields_update')->nullable();
|
||||
$table->string('width')->default('centered');
|
||||
$table->boolean('transparent_background')->default(false);
|
||||
$table->timestamp('closes_at')->nullable();
|
||||
$table->text('closed_text')->nullable();
|
||||
$table->string('notification_subject')->default("We saved your answers");
|
||||
$table->text('notification_body')->default('<p>Hello there 👋 <br>This is a confirmation that your submission was successfully saved.</p>');
|
||||
$table->boolean('notifications_include_submission')->default(true);
|
||||
$table->boolean('use_captcha')->default(false);
|
||||
$table->boolean('can_be_indexed')->default(true);
|
||||
$table->string('password')->nullable()->default(null);
|
||||
$table->string('notification_sender')->default("OpenForm");
|
||||
$table->jsonb('tags')->default('[]');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('forms');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class MakeFormsSoftDeletable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFormSubmissionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('form_submissions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\App\Models\Forms\Form::class,'form_id');
|
||||
$table->jsonb('data')->default('{}');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('form_submissions');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddHearAboutUsToUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('hear_about_us')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('hear_about_us');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFormZapierWebhooksTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('form_zapier_webhooks', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\App\Models\Forms\Form::class,'form_id');
|
||||
$table->string('hook_url');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('form_zapier_webhooks');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersWorkspacesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
\Illuminate\Support\Facades\DB::transaction(function () {
|
||||
|
||||
Schema::create('user_workspace', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('workspace_id')->unsigned();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->unique(['workspace_id', 'user_id']);
|
||||
$table->boolean('is_owner')->default(false);
|
||||
$table->string('access_token')->nullable();
|
||||
$table->foreign('workspace_id')->references('id')->on('workspaces')
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->foreign('user_id')->references('id')->on('users')
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// Add creator id to forms table
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->integer('creator_id')->unsigned()->nullable();
|
||||
$table->foreign('creator_id')->references('id')->on('users')
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
|
||||
// Create relation - can't use models because of new methods clash
|
||||
\Illuminate\Support\Facades\DB::table('workspaces')
|
||||
->orderBy('id')
|
||||
->chunk(100, function ($workspaces) {
|
||||
foreach ($workspaces as $workspace) {
|
||||
echo '.';
|
||||
|
||||
// Make sure user wasn't deleted
|
||||
if (!\Illuminate\Support\Facades\DB::table('users')->where('id',
|
||||
$workspace->user_id)->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create relation
|
||||
$now = now();
|
||||
\Illuminate\Support\Facades\DB::table('user_workspace')->insert([
|
||||
'workspace_id' => $workspace->id,
|
||||
'access_token' => $workspace->access_token,
|
||||
'user_id' => $workspace->user_id,
|
||||
'is_owner' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now
|
||||
]);
|
||||
|
||||
// Set form creator id
|
||||
foreach (\App\Models\Forms\Form::withTrashed()->where('workspace_id',$workspace->id)->get() as $form) {
|
||||
$form->update(['creator_id'=>$workspace->user_id]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Drop column
|
||||
Schema::table('workspaces', function (Blueprint $table) {
|
||||
$table->dropColumn(['user_id','access_token']);
|
||||
});
|
||||
|
||||
Schema::table('user_workspace', function (Blueprint $table) {
|
||||
$table->string('access_token')->nullable(false)->change();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
\Illuminate\Support\Facades\DB::transaction(function () {
|
||||
Schema::table('workspaces', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned()->nullable();
|
||||
$table->string('access_token')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
|
||||
// Remove relation
|
||||
\App\Models\Workspace::orderBy('id')
|
||||
->chunk(100, function ($workspaces) {
|
||||
foreach ($workspaces as $workspace) {
|
||||
if ($workspace->users()->count() == 0) {
|
||||
$workspace->delete();
|
||||
} else {
|
||||
$workspace->user_id = $workspace->users->first()->id;
|
||||
$workspace->access_token = $workspace->users()->withPivot('access_token')->first()->pivot->access_token;
|
||||
$workspace->save();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add creator id to forms table
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->dropColumn('creator_id');
|
||||
});
|
||||
Schema::dropIfExists('user_workspace');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJobBatchesTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->text('failed_job_ids');
|
||||
$table->text('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateWebhookCallsTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('webhook_calls', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('external_id')->nullable()->index();
|
||||
|
||||
$table->string('name');
|
||||
$table->json('payload')->nullable();
|
||||
$table->text('exception')->nullable();
|
||||
$table->timestamp('processed_at')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIndexesToImportantTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('form_submissions', function (Blueprint $table) {
|
||||
$table->index('form_id');
|
||||
});
|
||||
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->index('workspace_id');
|
||||
$table->index('slug');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('form_submissions', function (Blueprint $table) {
|
||||
$table->dropIndex('form_id');
|
||||
});
|
||||
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->dropIndex('workspace_id');
|
||||
$table->dropIndex('slug');
|
||||
});
|
||||
}
|
||||
}
|
||||
32
database/migrations/2022_05_02_092915_form_views.php
Normal file
32
database/migrations/2022_05_02_092915_form_views.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('form_views', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\App\Models\Forms\Form::class,'form_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('form_views');
|
||||
}
|
||||
};
|
||||
33
database/migrations/2022_05_10_144947_form_statistic.php
Normal file
33
database/migrations/2022_05_10_144947_form_statistic.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('form_statistics', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\App\Models\Forms\Form::class,'form_id');
|
||||
$table->jsonb('data')->default('{}');
|
||||
$table->date('date');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('form_statistics');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->jsonb('removed_properties')->default('[]');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->dropColumn('removed_properties');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->integer('max_submissions_count')->nullable()->default(null);
|
||||
$table->string('max_submissions_reached_text')->nullable()->default('This form has now reached the maximum number of allowed submissions and is now closed.');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->dropColumn('max_submissions_count');
|
||||
$table->dropColumn('max_submissions_reached_text');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('user_workspace', function (Blueprint $table) {
|
||||
$table->dropColumn('access_token');
|
||||
$table->dropColumn('is_owner');
|
||||
$table->string('role')->default('admin');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('workspaces', function (Blueprint $table) {
|
||||
$table->string('access_token')->nullable();
|
||||
$table->boolean('is_owner')->default(true);
|
||||
$table->dropColumn('role');
|
||||
});
|
||||
}
|
||||
};
|
||||
18
database/seeders/DatabaseSeeder.php
Normal file
18
database/seeders/DatabaseSeeder.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// \App\Models\User::factory(10)->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user