mirror of
https://github.com/hazemKrimi/crimson-vault.git
synced 2026-05-01 18:20:27 +00:00
wip: invoices api
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
-- Create "invoices" table
|
||||
CREATE TABLE `invoices` (
|
||||
`id` varchar NULL,
|
||||
`user_id` varchar NULL,
|
||||
`client_id` varchar NULL,
|
||||
`created_at` datetime NULL,
|
||||
`due_at` datetime NULL,
|
||||
`updated_at` datetime NULL,
|
||||
`deleted_at` datetime NULL,
|
||||
`reference` text NULL,
|
||||
`status` text NULL,
|
||||
`pdf` text NULL,
|
||||
`currency` text NULL,
|
||||
`vat` text NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
-- Create index "idx_invoices_deleted_at" to table: "invoices"
|
||||
CREATE INDEX `idx_invoices_deleted_at` ON `invoices` (`deleted_at`);
|
||||
-- Create "items" table
|
||||
CREATE TABLE `items` (
|
||||
`id` varchar NULL,
|
||||
`invoice_id` varchar NULL,
|
||||
`name` text NULL,
|
||||
`type` text NULL,
|
||||
`quantity` integer NULL,
|
||||
`tax` integer NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_invoices_items` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -0,0 +1,30 @@
|
||||
-- Disable the enforcement of foreign-keys constraints
|
||||
PRAGMA foreign_keys = off;
|
||||
-- Create "new_invoices" table
|
||||
CREATE TABLE `new_invoices` (
|
||||
`id` varchar NULL,
|
||||
`user_id` varchar NULL,
|
||||
`client_id` varchar NULL,
|
||||
`created_at` datetime NULL,
|
||||
`due_at` datetime NULL,
|
||||
`updated_at` datetime NULL,
|
||||
`deleted_at` datetime NULL,
|
||||
`reference` text NULL,
|
||||
`status` text NULL,
|
||||
`pdf` text NULL,
|
||||
`currency` text NULL,
|
||||
`vat` integer NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
-- Copy rows from old table "invoices" to new temporary table "new_invoices"
|
||||
INSERT INTO `new_invoices` (`id`, `user_id`, `client_id`, `created_at`, `due_at`, `updated_at`, `deleted_at`, `reference`, `status`, `pdf`, `currency`, `vat`) SELECT `id`, `user_id`, `client_id`, `created_at`, `due_at`, `updated_at`, `deleted_at`, `reference`, `status`, `pdf`, `currency`, `vat` FROM `invoices`;
|
||||
-- Drop "invoices" table after copying rows
|
||||
DROP TABLE `invoices`;
|
||||
-- Rename temporary table "new_invoices" to "invoices"
|
||||
ALTER TABLE `new_invoices` RENAME TO `invoices`;
|
||||
-- Create index "idx_invoices_deleted_at" to table: "invoices"
|
||||
CREATE INDEX `idx_invoices_deleted_at` ON `invoices` (`deleted_at`);
|
||||
-- Add column "user_id" to table: "items"
|
||||
ALTER TABLE `items` ADD COLUMN `user_id` varchar NULL;
|
||||
-- Enable back the enforcement of foreign-keys constraints
|
||||
PRAGMA foreign_keys = on;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Add column "price" to table: "items"
|
||||
ALTER TABLE `items` ADD COLUMN `price` integer NULL;
|
||||
@@ -1,2 +1,5 @@
|
||||
h1:2049NzfhHw8DDKsmQejeOcETj2pojlv5sA+O/QhmtG0=
|
||||
h1:dDD/MWKqjFIkCAuR4i/9LtH4ibg9wZR03FApuHHYCos=
|
||||
20250611102124.sql h1:HkDgtWXUxfAR9gIObTMzP98pVEIakerASGGSufW695k=
|
||||
20250616102420.sql h1:7C1kEskaDwdHmQOu3t48oZcky0WaNiFeIugJcJFkjKM=
|
||||
20250616150439.sql h1:nx8CvH5om7lbeEezo7roNcTV+f0agch0gBjYxKtTDn8=
|
||||
20250616151658.sql h1:O4hbYFj4bwMDML0mR9PtSn7GUbXQVCbh+lGkwTNBwnU=
|
||||
|
||||
Reference in New Issue
Block a user